# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.
#{
# acme_dns cloudflare xxx
#}
(log) {
log {
output file /var/log/caddy/{args[0]}.log {
roll_size 10MB
roll_keep 10
}
format filter {
wrap json
fields {
request>headers>Authorization delete
}
}
}
}
(_reverse_proxy) {
{args[0]}://{args[1]} {
reverse_proxy {args[2]} {
header_up X-Real-IP {remote_host}
}
handle /ip {
header Content-Type text/plain
respond `{remote_host}`
}
header -Server
import log {args[1]}
}
}
(http_reverse_proxy) {
import _reverse_proxy http {args[0]} {args[1]}
}
(reverse_proxy) {
import _reverse_proxy https {args[0]} {args[1]}
}
(http_reverse_proxy_no_log) {
http://{args[0]} {
reverse_proxy {args[1]} {
header_up X-Real-IP {remote_host}
}
header -Server
}
}
(reverse_proxy_no_log) {
{args[0]} {
reverse_proxy {args[1]} {
header_up X-Real-IP {remote_host}
}
header -Server
}
}
:80 {
import log default
abort
}
#import reverse_proxy "chungn.com" "homepage-nginx-1"
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile