diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 22:34:19 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 22:34:19 +0100 |
| commit | cd3f93bcc2d8e4a5934a19b13f7fdf30ee4e130c (patch) | |
| tree | c40914124410c0e5a407a14ba284774dbfbff03f /web/nginx.conf.example | |
| parent | v4.4.0: stable installers that follow the newest published build (diff) | |
| download | zagan-bet-cd3f93bcc2d8e4a5934a19b13f7fdf30ee4e130c.tar.gz zagan-bet-cd3f93bcc2d8e4a5934a19b13f7fdf30ee4e130c.zip | |
web: serve latest.php through PHP and refuse stray PHP files
nginx example now routes index.php and latest.php to php-fpm, sends the newest-version feed with no-store, keeps the stable installers revalidated, and returns 404 for every other .php request so releases.php cannot be downloaded as source. Documents Debian and Arch pool sockets.
Diffstat (limited to 'web/nginx.conf.example')
| -rw-r--r-- | web/nginx.conf.example | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/web/nginx.conf.example b/web/nginx.conf.example index ad001d1..9fc942f 100644 --- a/web/nginx.conf.example +++ b/web/nginx.conf.example | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | # zagan.bet download page — nginx + php-fpm example. | 1 | # zagan.bet download page — nginx + php-fpm example. |
| 2 | # | 2 | # |
| 3 | # Install at /etc/nginx/conf.d/zagan.bet.conf (the packaged nginx.conf includes | 3 | # Install at /etc/nginx/conf.d/zagan.bet.conf (the packaged nginx.conf includes |
| 4 | # conf.d/*.conf). Replace the server name, root and certificate paths. | 4 | # conf.d/*.conf). Replace the server name, root, socket and certificate paths. |
| 5 | # | 5 | # |
| 6 | # Only index.php is PHP; everything under /bin/ is served as static files. | 6 | # Only index.php and latest.php are PHP. Everything else under the web root is |
| 7 | # The binaries are versioned, so they can be cached forever — which means you | 7 | # static: /bin/ is immutable and versioned, while the installers are stable and |
| 8 | # must bump the version (Cargo.toml) instead of overwriting a published file. | 8 | # revalidated. Any other .php request is refused, so releases.php (an include) |
| 9 | # and stray scripts cannot be downloaded as source. | ||
| 9 | 10 | ||
| 10 | server { | 11 | server { |
| 11 | listen 80; | 12 | listen 80; |
| @@ -17,7 +18,7 @@ server { | |||
| 17 | server { | 18 | server { |
| 18 | listen 443 ssl; | 19 | listen 443 ssl; |
| 19 | listen [::]:443 ssl; | 20 | listen [::]:443 ssl; |
| 20 | http2 on; | 21 | http2 on; # nginx < 1.25.1: listen 443 ssl http2; |
| 21 | server_name dl.example.com; | 22 | server_name dl.example.com; |
| 22 | 23 | ||
| 23 | root /srv/zagan.bet; | 24 | root /srv/zagan.bet; |
| @@ -39,15 +40,41 @@ server { | |||
| 39 | # The page rescans bin/ on every request, so don't cache it. | 40 | # The page rescans bin/ on every request, so don't cache it. |
| 40 | location = /index.php { | 41 | location = /index.php { |
| 41 | include fastcgi_params; | 42 | include fastcgi_params; |
| 42 | fastcgi_pass unix:/run/php-fpm/php-fpm.sock; | 43 | # Debian/Ubuntu: /run/php/php-fpm.sock |
| 44 | # Arch: /run/php-fpm/php-fpm.sock | ||
| 45 | fastcgi_pass unix:/run/php/php-fpm.sock; | ||
| 43 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | 46 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 44 | add_header Cache-Control "no-cache"; | 47 | add_header Cache-Control "no-cache"; |
| 45 | } | 48 | } |
| 46 | 49 | ||
| 50 | # The newest-version feed read by install.sh and install.ps1. | ||
| 51 | location = /latest.php { | ||
| 52 | include fastcgi_params; | ||
| 53 | fastcgi_pass unix:/run/php/php-fpm.sock; | ||
| 54 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| 55 | add_header Cache-Control "no-store"; | ||
| 56 | } | ||
| 57 | |||
| 58 | # Stable installers: always revalidate so a fix reaches the next download. | ||
| 59 | location = /install.sh { | ||
| 60 | default_type text/plain; | ||
| 61 | add_header Cache-Control "no-cache"; | ||
| 62 | } | ||
| 63 | |||
| 64 | location = /install.ps1 { | ||
| 65 | default_type text/plain; | ||
| 66 | add_header Cache-Control "no-cache"; | ||
| 67 | } | ||
| 68 | |||
| 47 | location / { | 69 | location / { |
| 48 | try_files $uri $uri/ =404; | 70 | try_files $uri $uri/ =404; |
| 49 | } | 71 | } |
| 50 | 72 | ||
| 73 | # releases.php is an include only; no other script is meant to be served. | ||
| 74 | location ~ \.php$ { | ||
| 75 | return 404; | ||
| 76 | } | ||
| 77 | |||
| 51 | # Never serve dotfiles (.gitignore, editor leftovers). | 78 | # Never serve dotfiles (.gitignore, editor leftovers). |
| 52 | location ~ /\. { | 79 | location ~ /\. { |
| 53 | deny all; | 80 | deny all; |
