# Manual steps for Bryan - Andrea Slop Fotografie (ASF) test host (ordered, complete) Scope: test environment only. Nothing here touches production. Commands are drafted by the Pi-Main session (via "CMS & API") from this list; this list says WHAT and in WHICH ORDER. Items marked **(verify)** are facts from the inventory that were not verified by the author. Legend: **[Pi]** app Pi, **[Proxy]** proxy Pi 192.168.1.102, **[Gitea]** the CMS repository settings, **[Code]** needs the code on Gitea. ## Phase A - Prepare (nothing is live yet; the old nginx route keeps serving) 1. **[Pi] Verify prerequisites**: user `gitea-workflow` exists and has lingering enabled for user units (`loginctl enable-linger gitea-workflow`) (verify); `dotnet` runtime 10 is installed and its path is known (verify); port 5200 is free; the folder `/mnt/storage1/www/html/andreaslop-test` exists and `gitea-workflow` can read it (group/mode; the SlpSoftware setup needed a cross-account permission fix of the same kind) (verify). 2. **[Pi] Database** (sudo): create database `AndreaSlopFotografieTest` (utf8mb4) and user `AndreaSlopFotografie`@`localhost` with a strong password; grant all privileges on that database only. Note the password for step 4. Do not confuse with the WordPress database `andreaslop`. 3. **[Pi] Directories** as `gitea-workflow`: `apps/andreaslopfotografie/test/{releases,shared}`. Create the symlink `shared/wwwroot-web` -> `/mnt/storage1/www/html/andreaslop-test`. (Variant B, only if you choose it later: skip the symlink; the website pipeline then copies into `shared/wwwroot-web` itself.) 4. **[Pi] `shared/env`** (mode 600, owner `gitea-workflow`) with the variables from `infrastructure-design.md`: `ASPNETCORE_ENVIRONMENT`, `ASPNETCORE_URLS`, `ConnectionStrings__DefaultConnection`, `JwtSettings__Secret`, `Identity__Setup__Token`, `Observability__SentryDsn`, `Observability__Environment`, `ForwardedHeaders__KnownProxies__0`, `Logging__LogLevel__SlpModularCms.Website`. Generate the JWT secret (64+ chars) and the setup token (32+ chars) randomly; keep the token for step 17. 5. **[Pi] systemd user unit** `~/.config/systemd/user/andreaslopfotografie-test.service`: `WorkingDirectory=/current`, `EnvironmentFile=/shared/env`, `ExecStart= SlpModularCms.Api.AndreaSlopFotografie.dll`, `Restart=on-failure`, `KillSignal=SIGINT`, `WantedBy=default.target`. Run `systemctl --user daemon-reload` and `systemctl --user enable` (do **not** start yet: `current` does not exist until the first deploy). 6. **[Pi] Firewall**: allow 5200/tcp only from 192.168.1.102; verify with `ufw status`. 7. **[Pi, Pi-Main] Backup**: add `AndreaSlopFotografieTest` to the DB backup script. 8. **[Gitea] Variables** (repository SlpModularCms): `DEPLOY_PATH_ASF_TEST`, `SERVICE_NAME_ASF_TEST` (same form as the SlpSoftware one), `HEALTH_CHECK_URL_ASF_TEST=https://test.andreaslop.nl/health`, `VITE_SENTRY_DSN_ASF` (the website's Sentry DSN). The existing secrets `PI_MAIN_*` are reused: confirm they point at the same Pi and user. **Do NOT set `ASF_TEST_DEPLOY_ENABLED` yet.** Until it is `true` the ASF jobs are skipped and the pipeline stays as it is. 9. **[Code] Make the code available to Gitea**: this feature's branch must be pushed (or merged into master) before any deploy can run. I do not push; tell me when you want that. A merge to master with the switch off changes nothing for Andrea. ## Phase B - Cut over (this causes the short test downtime you accepted) 10. **[Proxy] Save the current server block** for `test.andreaslop.nl` (copy the file; this is the revert point). 11. **[Proxy] Switch the route**: the block for `test.andreaslop.nl` (website repo copy: `web/deploy/nginx/test.andreaslop.nl.proxy.conf`, generated by `web/config/serverConfig.ts`) already sets `Host`, `X-Forwarded-For` (`$proxy_add_x_forwarded_for`), `X-Forwarded-Proto` (`$scheme`) and `X-Real-IP`. **Verify** these three forwarded headers are present in the live block (grep), then change only the target: `proxy_pass http://192.168.1.103;` (port 80, nginx fallback) -> `proxy_pass http://192.168.1.103:5200;`. Keep the certbot TLS settings. Test the config, reload nginx. Until the first deploy the site answers 502/503 (expected). The generator in the website repo is updated in U3 so the repo copy matches. 12. **[Gitea] Set `ASF_TEST_DEPLOY_ENABLED=true`.** 13. **[Gitea/Code] Run the first deploy**: push to master, or start "Continuous Integration" manually with the box "Deploy ASF test" ticked. Watch the job: build admin, publish, upload, link, switch, restart, `/health` check on the public URL, prune. ## Phase C - Verify (can be done together with this session) 14. `curl -I https://test.andreaslop.nl/` -> 200 with CSP, HSTS, `X-Robots-Tag: noindex, nofollow`; `/over-mij` (or any page) 200; `/Over-Mij` -> one 301; an unknown path -> 404 with the 404 page; `/robots.txt` -> `Disallow: /`. 15. `https://test.andreaslop.nl/health` -> healthy; `/api/v1/System/capabilities` -> no `Offerings`. 16. `/admin/`: Andrea's theme, Dutch; the setup page asks for the setup token. 17. Create the first administrator with the setup token. Afterwards **remove `Identity__Setup__Token` from `shared/env`** and restart the unit (the setup endpoint is closed once initialised; removing the token is hygiene). 18. Report what you see for the forwarded headers (visitor address in the logs/limiter rather than 192.168.1.102) and optionally time a page request on the Pi; both are asked for in the hand-back. ## Rollback - **Release**: `ln -sfn releases/ current` and `systemctl --user restart andreaslopfotografie-test`. - **Route**: restore the saved nginx block on the proxy Pi (step 10) and reload; the old nginx fallback on the app Pi serves the test site again. - **Switch off CI**: set `ASF_TEST_DEPLOY_ENABLED` to anything but `true`. ## Optional, separate (existing hosts; only if you want per-visitor rate limits there too) - **SlpSoftware test**: add `ForwardedHeaders__KnownProxies__0=192.168.1.102` to its `shared/env`, make sure its proxy-Pi block sets `X-Forwarded-For`/`-Proto`, restart the unit after the next deploy of the new code. - **SlpSoftware production and other hosts**: the same two things, later, when you decide. Until then they behave exactly as before. - Production Andrea: out of scope for this feature (when it comes: `Website__NoIndex=false`, its own database/port 5201/route).