Caddyfile Directives

Directives are functional keywords that appear within site blocks. Sometimes, they may open blocks of their own which can contain subdirectives, but directives cannot be used within other directives unless noted. For example, you can't use basic_auth inside a file_server block, because file_server does not know how to do authentication. However, you may use some directives within special directive blocks like handle and route because they are specifically designed to group HTTP handler directives.

The following directives come standard with Caddy, and can be used in the HTTP Caddyfile:

Directive Description
abort Aborts the HTTP request
acme_server An embedded ACME server
basic_auth Enforces HTTP Basic Authentication
bind Customize the server's socket address
encode Encodes (usually compresses) responses
error Trigger an error
file_server Serve files from disk
forward_auth Delegate authentication to an external service
fs Set the file system to use for file I/O
handle A mutually-exclusive group of directives
handle_errors Defines routes for handling errors
handle_path Like handle, but strips path prefix
header Sets or removes response headers
import Include snippets or files
intercept