「Caddy」:修訂間差異
跳至導覽
跳至搜尋
(未顯示同一使用者於中間所作的 3 次修訂) | |||
第7行: | 第7行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
curl -Lfs https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg; echo -e "deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main\ndeb-src [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy-stable.list; sudo apt update; sudo apt install -y caddy; sudo apt clean | curl -Lfs https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg; echo -e "deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main\ndeb-src [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy-stable.list; sudo apt update; sudo apt install -y caddy; sudo apt clean | ||
</syntaxhighlight> | |||
== 設定 == | |||
重複使用設定的方法: | |||
<syntaxhighlight lang="nginx"> | |||
(subdomain-log) { | |||
log { | |||
format transform `{request>remote_ip} - {request>user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` { | |||
time_format "02/Jan/2006:15:04:05 +0000" | |||
} | |||
output file /var/log/caddy/{args[0]}_access.log { | |||
mode 0640 | |||
} | |||
} | |||
} | |||
bar.example.com { | |||
# ... | |||
import subdomain-log bar.example.com | |||
# ... | |||
} | |||
foo.example.com { | |||
# ... | |||
import subdomain-log foo.example.com | |||
# ... | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
於 2025年4月4日 (五) 09:31 的最新修訂
Caddy是一個HTTP伺服器,主打自動化HTTPS以及簡易的設定。
安裝
在Debian與Ubuntu上都可以使用官方的APT repository安裝:
curl -Lfs https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg; echo -e "deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main\ndeb-src [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy-stable.list; sudo apt update; sudo apt install -y caddy; sudo apt clean
設定
重複使用設定的方法:
(subdomain-log) {
log {
format transform `{request>remote_ip} - {request>user_id} [{ts}] "{request>method} {request>uri} {request>proto}" {status} {size} "{request>headers>Referer>[0]}" "{request>headers>User-Agent>[0]}"` {
time_format "02/Jan/2006:15:04:05 +0000"
}
output file /var/log/caddy/{args[0]}_access.log {
mode 0640
}
}
}
bar.example.com {
# ...
import subdomain-log bar.example.com
# ...
}
foo.example.com {
# ...
import subdomain-log foo.example.com
# ...
}
外部連結
- 官方網站 (英文)