[Caddy2] Caddyfile 指令

 

如下是 Caddyfile 的標準指令。php

acme_server An embedded ACME server
basicauth Enforces HTTP Basic Authentication
bind Customize the server's socket address
encode Encodes (usually compresses) responses
file_server Serve files from disk
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
log Enables access/request logging
php_fastcgi Serve PHP sites over FastCGI
redir Issues an HTTP redirect to the client
request_header Manipulates request headers
respond Writes a hard-coded response to the client
reverse_proxy A powerful and extensible reverse proxy
rewrite Rewrites the request internally
root Set the path to the site root
route A group of directives treated literally as single unit
templates Execute templates on the response
tls Customize TLS settings
try_files Rewrite that depends on file existence
uri Manipulate the URI

 

 

指令的語法格式以下:html

directive [<matcher>] <args...> { subdirective [<args...>] }

< > 中使用實際的值替換,[ ] 表明是可選的參數,... 表明一個或多個值。socket

 

大多數指令接受 [<matcher>] 來過濾請求,表示不一樣的請求使用不一樣的指令。編碼

 

許多指令操縱 HTTP 處理程序鏈。這些指令的求值順序很重要,所以默認的順序被硬編碼到 Caddy 中。spa

root header redir rewrite uri try_files basicauth request_header encode templates handle handle_path route respond reverse_proxy php_fastcgi file_server acme_server

若是須要自定義順序,能夠使用 order 全局選項,或者 route 指令。code

 

Link:https://www.cnblogs.com/farwish/p/13100255.htmlserver

相關文章
相關標籤/搜索