| 1 | # Serve the generated static site; route only Mercurial wire-protocol |
| 2 | # requests (?cmd=...) to hgweb. Browsers and scrapers never reach hgweb. |
| 3 | |
| 4 | upstream hgweb { |
| 5 | server unix:/run/hgweb/hgweb.sock; |
| 6 | } |
| 7 | |
| 8 | server { |
| 9 | listen 443 ssl; |
| 10 | server_name code.example.org; |
| 11 | # ssl_certificate ...; ssl_certificate_key ...; |
| 12 | |
| 13 | root /var/www/hg; |
| 14 | |
| 15 | location / { |
| 16 | # Real hg clients are the only thing that sends ?cmd=. |
| 17 | if ($arg_cmd) { |
| 18 | rewrite ^ /_hgwire$uri last; |
| 19 | } |
| 20 | try_files $uri $uri/ =404; |
| 21 | } |
| 22 | |
| 23 | location /_hgwire/ { |
| 24 | internal; |
| 25 | rewrite ^/_hgwire(/.*)$ $1 break; |
| 26 | proxy_pass http://hgweb; |
| 27 | # Stream bundles instead of spooling them to disk. |
| 28 | proxy_buffering off; |
| 29 | proxy_set_header Host $host; |
| 30 | proxy_set_header X-Forwarded-Proto $scheme; |
| 31 | } |
| 32 | } |