tenseleyflow/shithub / b96a9a8

Browse files

S37: Caddyfile template (TLS + git smart-HTTP timeouts)

Authored by espadonne
SHA
b96a9a834f2909105dbc13379c047c25df42f5fe
Parents
0dd44ce
Tree
f8147ea

1 changed file

StatusFile+-
A deploy/Caddyfile.j2 59 0
deploy/Caddyfile.j2added
@@ -0,0 +1,59 @@
1
+# Managed by Ansible.
2
+#
3
+# Caddy reverse-proxies shithubd-web (127.0.0.1:8080). Auto-cert
4
+# from Let's Encrypt for {{ shithub_domain }}; HTTP→HTTPS redirect
5
+# is automatic when a `https://` site is declared. Long-timeout
6
+# overrides on the git smart-HTTP routes match the 30-minute
7
+# upstream timeout from S12 so push of a large repo doesn't get
8
+# guillotined by Caddy's defaults.
9
+
10
+{
11
+    # Operator email used for Let's Encrypt account + expiry alerts.
12
+    email {{ shithub_admin_email | default("ops@" + shithub_domain) }}
13
+
14
+    # Use staging during dry-runs to avoid LE rate limits.
15
+    # Comment the next line out for production cert.
16
+    # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
17
+}
18
+
19
+{{ shithub_domain }} {
20
+    encode gzip
21
+
22
+    # Long-timeout git smart-HTTP routes (S12). The fetch + push
23
+    # subprotocols stream and benefit from the buffer being off.
24
+    @git path_regexp gitp ^/[^/]+/[^/]+\.git/(info/refs|git-upload-pack|git-receive-pack)$
25
+    handle @git {
26
+        reverse_proxy 127.0.0.1:8080 {
27
+            transport http {
28
+                read_timeout 30m
29
+                write_timeout 30m
30
+                response_header_timeout 30m
31
+            }
32
+            flush_interval -1
33
+        }
34
+    }
35
+
36
+    # Static assets: long cache.
37
+    @static path /static/*
38
+    handle @static {
39
+        header Cache-Control "public, max-age=86400"
40
+        reverse_proxy 127.0.0.1:8080
41
+    }
42
+
43
+    handle {
44
+        reverse_proxy 127.0.0.1:8080 {
45
+            transport http {
46
+                read_timeout 60s
47
+                write_timeout 60s
48
+            }
49
+        }
50
+    }
51
+
52
+    log {
53
+        output file /var/log/caddy/access.log {
54
+            roll_size 100mb
55
+            roll_keep 14
56
+        }
57
+        format json
58
+    }
59
+}