docker/nginx.conf
nginx.confhistorycomment on this file
| 1 | worker_processes 1; |
| 2 | pid /run/nginx.pid; |
| 3 | |
| 4 | events { |
| 5 | worker_connections 1024; |
| 6 | } |
| 7 | |
| 8 | http { |
| 9 | access_log /dev/stdout; |
| 10 | error_log /dev/stderr; |
| 11 | |
| 12 | server { |
| 13 | listen 8080; |
| 14 | |
| 15 | # git smart-HTTP for the single hosted repository, addressed the |
| 16 | # same way any GitHub-style remote is (`git-ents/git-ents.git`) |
| 17 | # rather than a bespoke `/repo.git` — still exactly one |
| 18 | # repository (`roots.single-node-hosted`: stock git stays the |
| 19 | # one git transport; the web process adds none of its own), |
| 20 | # just no longer named like it might be more than one. |
| 21 | location ~ ^/git-ents/git-ents\.git(/.*)?$ { |
| 22 | # git push can be large; never buffer it into a temp file. |
| 23 | client_max_body_size 0; |
| 24 | gzip off; |
| 25 | |
| 26 | include /etc/nginx/fastcgi_params; |
| 27 | fastcgi_pass unix:/run/fcgiwrap.sock; |
| 28 | fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; |
| 29 | fastcgi_param GIT_HTTP_EXPORT_ALL ""; |
| 30 | fastcgi_param GIT_PROJECT_ROOT /data; |
| 31 | fastcgi_param PATH_INFO $uri; |
| 32 | # git-http-backend spawns receive-pack, which runs our hooks, |
| 33 | # which shell to the sprite CLI (`ents-effect`'s |
| 34 | # `SpriteExecutor`) — fcgiwrap otherwise hands CGI processes a |
| 35 | # minimal environment with no PATH at all. |
| 36 | fastcgi_param PATH "/usr/local/bin:/usr/bin:/bin"; |
| 37 | } |
| 38 | |
| 39 | # A clone URL without the trailing `.git` |
| 40 | # (`git clone https://git.ents.cloud/git-ents/git-ents`) redirects |
| 41 | # to the canonical `.git` path above. git's http client re-issues |
| 42 | # every request of the clone/fetch/push against the redirected |
| 43 | # base, not just this first one, so one redirect here is enough. |
| 44 | # |
| 45 | # Hardcoded `https://`, not `$scheme`: Fly's edge terminates TLS |
| 46 | # and always forwards plain HTTP to this app (`force_https=true` |
| 47 | # in fly.toml already guarantees no real client reaches here over |
| 48 | # HTTP), so `$scheme` as nginx sees it is always `http` and would |
| 49 | # downgrade every redirected client to plaintext. |
| 50 | location = /git-ents/git-ents { |
| 51 | return 301 https://$host/git-ents/git-ents.git; |
| 52 | } |
| 53 | location ~ ^/git-ents/git-ents/(.*)$ { |
| 54 | return 301 https://$host/git-ents/git-ents.git/$1$is_args$args; |
| 55 | } |
| 56 | |
| 57 | # The server key's public half (`git ents setup --hosted` writes |
| 58 | # `<key>.pub`): served by nginx itself, not the web process, so |
| 59 | # `git ents bootstrap` can discover the identity to vouch for |
| 60 | # during the exact window the web UI is still fail-closed |
| 61 | # awaiting that enrollment (`roots.web-signing`). |
| 62 | location = /.ents/server-key { |
| 63 | default_type text/plain; |
| 64 | alias /data/hosted_signing_key.pub; |
| 65 | } |
| 66 | |
| 67 | # Everything else: the hosted web UI (`git ents serve --hosted`), |
| 68 | # loopback-only inside this machine — nginx is the sole external |
| 69 | # listener. |
| 70 | location / { |
| 71 | proxy_pass http://127.0.0.1:4880; |
| 72 | proxy_set_header Host $host; |
| 73 | proxy_set_header X-Forwarded-Proto $scheme; |
| 74 | proxy_http_version 1.1; |
| 75 | } |
| 76 | } |
| 77 | } |