Created
July 28, 2026 09:47
-
-
Save leesei/3009ee11a0525cca0f815e305ac7f566 to your computer and use it in GitHub Desktop.
Sample Caddyfile (Caddy v2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://caddyserver.com/docs/caddyfile/options#global-options | |
| { | |
| # debug | |
| # email address used for ACME registration | |
| email user@domain.com | |
| # use staging ACME CA for development | |
| # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory | |
| } | |
| (cors) { | |
| @origin{args[0]} header Origin {args[0]} | |
| header @origin{args[0]} Access-Control-Allow-Origin "{args[0]}" | |
| header @origin{args[0]} Access-Control-Request-Method GET,POST,PUT,OPTIONS | |
| header @origin{args[0]} Access-Control-Max-Age 3600 | |
| header @origin{args[0]} Access-Control-Allow-Credentials false | |
| header @origin{args[0]} Access-Control-Allow-Headers "X-Token, Accept, Authorization, Content | |
| -Type, If-None-Match" | |
| } | |
| (log_common) { | |
| log { | |
| level debug | |
| output file /var/log/caddy/{args[0]}.access.log { | |
| roll_size 200MiB | |
| roll_keep_for 30d | |
| } | |
| format json { | |
| time_format iso8601 | |
| } | |
| #format console | |
| } | |
| } | |
| static.example.com { | |
| import log_common static | |
| # tls internal | |
| root * /var/www | |
| file_server | |
| } | |
| app1.example.com { | |
| import log_common app1 | |
| # allows CORS requests from this URL | |
| import cors https://app1.netlify.app | |
| # tls internal | |
| reverse_proxy http://localhost:8000 | |
| } | |
| http://:8080 { | |
| import log_common localhost | |
| root * /var/www | |
| file_server | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment