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/README.md | |
| 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 '')
| -rw-r--r-- | web/README.md | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/web/README.md b/web/README.md index 13f5f85..81346fd 100644 --- a/web/README.md +++ b/web/README.md | |||
| @@ -71,34 +71,46 @@ Cargo itself cannot produce these names: it always writes | |||
| 71 | ## nginx | 71 | ## nginx |
| 72 | 72 | ||
| 73 | `web/nginx.conf.example` is a working server block for a subdomain with an | 73 | `web/nginx.conf.example` is a working server block for a subdomain with an |
| 74 | existing certificate. On Arch-based systems: | 74 | existing certificate. Debian/Ubuntu and Arch install it the same way: |
| 75 | 75 | ||
| 76 | ```sh | 76 | ```sh |
| 77 | # Debian / Ubuntu | ||
| 78 | sudo apt install nginx php-fpm | ||
| 79 | sudo install -d -o "$USER" -g www-data -m 0755 /srv/zagan.bet | ||
| 80 | |||
| 81 | # Arch | ||
| 77 | sudo pacman -S nginx php-fpm | 82 | sudo pacman -S nginx php-fpm |
| 78 | sudo install -d -o "$USER" -g http -m 0755 /srv/zagan.bet | 83 | sudo install -d -o "$USER" -g http -m 0755 /srv/zagan.bet |
| 84 | |||
| 79 | sudo cp web/nginx.conf.example /etc/nginx/conf.d/zagan.bet.conf | 85 | sudo cp web/nginx.conf.example /etc/nginx/conf.d/zagan.bet.conf |
| 80 | # edit server_name, root and the certificate paths, then: | 86 | # edit server_name, root, socket and certificate paths, then: |
| 81 | sudo nginx -t && sudo systemctl enable --now nginx php-fpm | 87 | sudo nginx -t && sudo systemctl enable --now nginx php-fpm |
| 82 | ``` | 88 | ``` |
| 83 | 89 | ||
| 84 | The pool socket and user are Arch defaults (`http`, | 90 | The example uses Debian/Ubuntu's pool socket (`/run/php/php-fpm.sock`); Arch |
| 85 | `/run/php-fpm/php-fpm.sock`). Check them and adjust `fastcgi_pass` if your | 91 | uses `/run/php-fpm/php-fpm.sock`. Check the pool's user and socket and adjust |
| 86 | distribution differs: | 92 | `fastcgi_pass` if your distribution differs: |
| 87 | 93 | ||
| 88 | ```sh | 94 | ```sh |
| 89 | grep -E '^(user|group|listen)' /etc/php/php-fpm.d/www.conf | 95 | grep -E '^(user|group|listen)' /etc/php/*/fpm/pool.d/www.conf /etc/php-fpm.d/www.conf 2>/dev/null |
| 90 | ``` | 96 | ``` |
| 91 | 97 | ||
| 92 | `rsync` publishes files as `0755`/`0644`, so the `http` worker and the php-fpm | 98 | `rsync` publishes files as `0755`/`0644`, so the PHP worker can read them |
| 93 | pool can read them without extra group juggling. `index.php` is the only | 99 | without extra group juggling. `index.php` and `latest.php` are the only |
| 94 | script; any other `.php` request 404s instead of executing. | 100 | scripts; `releases.php` is an include, and the example returns 404 for every |
| 101 | other `.php` request instead of serving it as source. | ||
| 102 | |||
| 103 | The example sends `/latest.php` with `no-store` and the two installers with | ||
| 104 | `no-cache`, so a new release is picked up immediately without giving up the | ||
| 105 | immutable caching on `/bin/`. | ||
| 95 | 106 | ||
| 96 | PHP's opcache is enabled by default and revalidates timestamps every two | 107 | PHP's opcache is enabled by default and revalidates timestamps every two |
| 97 | seconds, so a deployed `index.php` takes effect without reloading php-fpm. If | 108 | seconds, so a deployed `index.php` or `latest.php` takes effect without |
| 98 | you ever set `opcache.validate_timestamps=0`, reload php-fpm after a deploy. | 109 | reloading php-fpm. If you ever set `opcache.validate_timestamps=0`, reload |
| 110 | php-fpm after a deploy. | ||
| 99 | 111 | ||
| 100 | The php-fpm unit on Arch uses `PrivateTmp=`, so the hash cache in `/tmp` lives | 112 | The php-fpm unit often uses `PrivateTmp=`, so the hash cache in `/tmp` lives in |
| 101 | in the service's private tmp. It still works; point `ZAGAN_HASH_CACHE` at a | 113 | the service's private tmp. It still works; point `ZAGAN_HASH_CACHE` at a |
| 102 | writable path such as `/var/cache/zagan-bet-hashes.json` if you want it to | 114 | writable path such as `/var/cache/zagan-bet-hashes.json` if you want it to |
| 103 | survive a service restart. | 115 | survive a service restart. |
| 104 | 116 | ||
