interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / infra / nginx / snippets / forge-proxy.conf
| 1 | # /etc/nginx/snippets/forge-proxy.conf on hub - shared proxy settings for every forged location. |
| 2 | # Include inside a location, then set X-Forge-Base and proxy_pass in that same location |
| 3 | # (proxy_set_header there replaces the inherited list, so every header lives in one place). |
| 4 | # Requires conf.d/forge.conf (upstream forged, zone forge_post, map $forge_post_noaddr). |
| 5 | |
| 6 | if ($forge_post_noaddr) { return 503; } |
| 7 | limit_except GET HEAD POST { deny all; } |
| 8 | limit_req zone=forge_post burst=10 nodelay; |
| 9 | limit_req zone=forge_other_reads burst=30 nodelay; |
| 10 | limit_req zone=forge_source_pages burst=128 delay=8; |
| 11 | limit_req zone=forge_bots burst=10; |
| 12 | limit_req_status 429; |
| 13 | limit_conn forge_git_history 3; |
| 14 | limit_conn_status 429; |
| 15 | |
| 16 | # Body size: client_max_body_size is the including server block's (64k on interplane.io), so the |
| 17 | # one location that takes larger bodies (the git patch upload, 3145728 bytes) can raise it; set |
| 18 | # here too, it would be a duplicate directive in that location. |
| 19 | client_body_buffer_size 64k; |
| 20 | |
| 21 | # forged speaks HTTP/1.1, but nginx->upstream stays HTTP/1.0 + Connection: close: one |
| 22 | # request per connection, so a close-delimited streamed body is always well framed. |
| 23 | proxy_http_version 1.0; |
| 24 | proxy_connect_timeout 5s; |
| 25 | proxy_send_timeout 30s; |
| 26 | # proxy_read_timeout is nginx's default 60s here; forge-archive.conf raises it to 300s |
| 27 | # (setting it in both files would be a duplicate directive in the archive locations). |
| 28 | proxy_redirect off; |
| 29 | proxy_intercept_errors off; |
| 30 | |
| 31 | # forged serves one connection at a time, so a slow reader must never hold it (security review |
| 32 | # P2-1). nginx reads every response from forged at tunnel speed and spools what the client has |
| 33 | # not taken yet to /var/lib/nginx/proxy (cap 600m per response; forged's own cap is 512 MiB). |
| 34 | # A client that accepts nothing for 60 s is dropped. |
| 35 | proxy_buffering on; |
| 36 | proxy_max_temp_file_size 600m; |
| 37 | send_timeout 60s; |
| 38 | |
| 39 | # Client copies of these headers never reach forged: every one is overwritten here. |
| 40 | proxy_set_header Host $host; |
| 41 | proxy_set_header X-Real-IP $proxy_protocol_addr; |
| 42 | proxy_set_header X-Forwarded-For $proxy_protocol_addr; |
| 43 | proxy_set_header X-Forwarded-Proto https; |
| 44 | proxy_set_header X-Forwarded-Host $host; |
| 45 | proxy_set_header Authorization ""; |
| 46 | proxy_set_header Proxy ""; |
| 47 | |
| 48 | # The edge headers (forge-headers.conf) are authoritative, except Content-Security-Policy: |
| 49 | # forged's own policy (page or raw sandbox) passes through, see $forge_csp_edge in conf.d/forge.conf. |
| 50 | proxy_hide_header Strict-Transport-Security; |
| 51 | proxy_hide_header X-Frame-Options; |
| 52 | proxy_hide_header Referrer-Policy; |
| 53 | proxy_hide_header X-Content-Type-Options; |
| 54 | proxy_hide_header X-Powered-By; |