使用Caddy配置反向代理

Gao
使用Caddy做为服务网关 配置方式 ``` (route53) { tls { ca https://acme-v02.api.letsencrypt.org/directory dns route53 { max_retries 3 } resolvers 8.8.8.8 1.1.1.1 } } *.gsmlg.net { import route53 @router host srv.gsmlg.net handle @router { reverse_proxy localhost:8080 } @nexus host addr.gsmlg.net handle @nexus { reverse_proxy localhost:8081 } @pve host secure.gsmlg.net handle @pve { reverse_proxy https://1.2.4.8:8088 { header_up Host {upstream_hostport} header_up X-Forwarded-Host {host} header_down content-security-policy "default-src 'none'; base-uri 'self'; block-all-mixed-content;" transport http { tls_insecure_skip_verify } } } } ``` 增加简单认证 ``` # 生产密码 # caddy hash-password [--algorithm <name>] [--salt <string>] [--plaintext <password>] gsmlg.net { reverse_proxy localhost:10280 { } basicauth /admin* { Josh {env.PASSWD} } basicauth /graph* { Josh {env.PASSWD} } @api_cud { method POST PUT DELETE path /api/* } basicauth @api_cud { Josh {env.PASSWD} } } ``` 重定向 ``` www.gsmlg.net { redir https://gsmlg.net{uri} } ``` 文件服务 ``` file.gsmlg.net { root * /var/www/static file_server } ```