Skip to content

常用配置

https://caddyserver.com/docs/caddyfile

域名会默认开启https,ip不会

静态目录

caddyfile
localhost

encode zstd gzip # 开启压缩
templates # 开启模板
file_server browse # 静态服务

单页应用

caddyfile
example.com {
    root * /path/to/site
    encode gzip
    try_files {path} /index.html
    file_server
}

单页应用 + 接口转发

caddyfile
example.com {
    encode gzip

    handle /api/* {
        reverse_proxy backend:8000
    }

    handle {
        root * /path/to/site
        try_files {path} /index.html
        file_server
    }
}