当符合下面一些合理的标准时,Caddy会自动为所有站点启用HTTPS:
Caddy还会将所有HTTP请求重定向到与HTTPS对应的地址,只要Caddyfile中没有定义主机名的纯文本变体。
yamlversion: "3"
services:
caddy:
container_name: caddy
image: caddy:alpine
restart: unless-stopped
ports:
- "80:80"
- "80:80/udp"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy/:/data/caddy/
Caddyfile:80 { redir https://{host}{uri} } uing.vip { log { output stdout format console level ERROR } root * /var/www/uing.vip handle_errors { rewrite * /404.html file_server } file_server } gitea.uing.vip { log { output stdout format console level ERROR } reverse_proxy gitea:3000 } https://example.com { reverse_proxy localhost:8080 { header_up Host {host} header_up X-Real-IP {remote_host} header_up X-Forwarded-For {remote_host} header_up X-Forwarded-Proto {scheme} } }
yamlversion: "3"
services:
caddy:
container_name: caddy
build:
dockerfile: ./caddy-cloudflare-Dockerfile
restart: unless-stopped
ports:
- "80:80"
- "80:80/udp"
- "443:443"
- "443:443/udp"
environment:
- CF_API_TOKEN=XXX
- DOMAIN=XXX
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy:/data/caddy
Caddyfile{env.DOMAIN} { log { output stdout format console level ERROR } reverse_proxy gitea:3000 }
DockerfileFROM caddy:builder-alpine AS builder RUN xcaddy build --with github.com/caddy-dns/cloudflare FROM caddy:alpine COPY --from=builder /usr/bin/caddy /usr/bin/caddy
本文作者:菜鸟
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 许可协议。转载请注明出处!