[mirror] Scalable static site server for Git forges (like GitHub Pages)

Configure Caddy to use HTTP/3.

Also, add `Alt-Svc:` headers for both H2 and H3.

+2 -3
Dockerfile
··· 35 35 RUN mkdir /app/data 36 36 COPY conf/supervisord.conf /app/supervisord.conf 37 37 COPY conf/Caddyfile /app/Caddyfile 38 - RUN caddy adapt -c Caddyfile -p >/app/caddy.json 39 38 COPY conf/config.toml.example /app/config.toml 40 39 41 40 # Caddy ports: 42 - EXPOSE 80 443 2019 41 + EXPOSE 80/tcp 443/tcp 443/udp 2019/tcp 43 42 # git-pages ports: 44 - EXPOSE 3000 3001 3002 43 + EXPOSE 3000/tcp 3001/tcp 3002/tcp 45 44 46 45 # While the default command is to run git-pages standalone, the intended configuration 47 46 # is to use it with Caddy and store both site data and credentials to an S3-compatible
+22 -8
conf/Caddyfile
··· 40 40 protocols h1 h2 41 41 } 42 42 43 + servers {$UDP_BIND_TO:0.0.0.0}:443 { 44 + name http3 45 + protocols h3 46 + } 47 + 43 48 servers :2002 { 44 49 name health 45 50 protocols h1 46 51 } 47 52 } 48 53 49 - (backend_pages) { 54 + (backend) { 55 + tls { 56 + on_demand 57 + } 58 + 50 59 @h2c `{env.FEATURES}.matches(r"\bh2c\b")` 51 60 reverse_proxy @h2c h2c://{$GIT_PAGES_ADDRESS:localhost}:3000 52 61 reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3000 62 + 63 + header Alt-Svc `h3=":443"; persist=1, h2=":443"; persist=1` 64 + encode 53 65 } 54 66 55 67 http:// { 68 + # initial PUT/POST for a new domain has to happen over HTTP 56 69 @get method GET 57 70 redir @get https://{host}{uri} 301 58 71 59 - # initial PUT/POST for a new domain has to happen over HTTP 60 - import backend_pages 72 + import backend 61 73 } 62 74 63 75 https:// { 64 - tls { 65 - on_demand 66 - } 76 + import backend 77 + } 78 + 79 + https:// { 80 + # Fly.io requires UDP sockets to be bound to a different IP 81 + bind {$UDP_BIND_TO:0.0.0.0} 67 82 68 - encode 69 - import backend_pages 83 + import backend 70 84 } 71 85 72 86 http://localhost:2002 {
+1 -1
conf/supervisord.conf
··· 12 12 command = /bin/git-pages 13 13 14 14 [program:caddy] 15 - command = /bin/caddy run -c caddy.json 15 + command = /bin/caddy run 16 16 depends_on = pages
+9
fly.toml
··· 17 17 memory = 512 18 18 19 19 [env] 20 + UDP_BIND_TO = "fly-global-services" 20 21 AUTOMEMLIMIT = "0.25" 21 22 22 23 [[files]] ··· 33 34 [[services]] 34 35 internal_port = 443 35 36 protocol = "tcp" 37 + ports = [{ port = 443 }] 38 + auto_stop_machines = "stop" 39 + auto_start_machines = true 40 + 41 + # NB: Fly.io does not support UDP on public IPv6 42 + [[services]] 43 + internal_port = 443 44 + protocol = "udp" 36 45 ports = [{ port = 443 }] 37 46 auto_stop_machines = "stop" 38 47 auto_start_machines = true