Production upload over FTPS (explicit TLS, no fallback) #26
@@ -369,13 +369,13 @@ jobs:
|
||||
name: dist
|
||||
path: web/dist
|
||||
|
||||
# Gewone FTP (het productiepakket biedt geen FTPS) naar de map met
|
||||
# FTP over TLS (FTPS, explicit, zonder terugval) naar de map met
|
||||
# voorgerenderde pagina's van de CMS-host, in drie rondes (zie
|
||||
# deploy/upload-production.sh): eerst alles behalve HTML, dan alle HTML,
|
||||
# en pas daarna oude bestanden opruimen. Zo verwijst een bezoeker nooit
|
||||
# naar een bestand dat er nog niet staat. De host zelf en zijn web.config
|
||||
# komen uit de CMS-pijplijn. Deze job kan pas draaien als er een webhost is.
|
||||
- name: Upload naar productie (gewone FTP)
|
||||
- name: Upload naar productie (FTPS)
|
||||
env:
|
||||
FTP_HOST: ${{ secrets.PROD_HOST_ADDRESS }}
|
||||
FTP_PORT: ${{ secrets.PROD_HOST_PORT }}
|
||||
|
||||
@@ -51,7 +51,7 @@ The hero of the homepage comes from the CMS hero module (`GET /api/v1/hero`); th
|
||||
Decision (Bryan, 2026-11-15): the hosting package has one entry per website. The CMS host (Kestrel) is that entry and serves the website itself (the prerendered pages), `/admin` and `/api/v1/*`. In production IIS (or the proxy) therefore passes **all** requests to the CMS host, not only `/api/v1/*`, and serves no static files or HTML cache of its own. This holds for the test host and for ASF production alike.
|
||||
|
||||
- **Test (ASF):** nginx on the proxy Pi forwards everything for `test.andreaslop.nl` to the CMS host (`web/deploy/nginx/test.andreaslop.nl.proxy.conf`), which serves the site files and the API. Nothing to add.
|
||||
- **Production: not in place yet.** The FTP upload (`web/deploy/upload-production.sh`) is now plain FTP into the CMS host's prerendered-pages folder and no longer puts a `web.config` on the server (the host's own `web.config` comes from the CMS pipeline). The generated `web/deploy/iis/web.config` still describes the old idea of IIS serving the files and has to change with the production hosting: IIS keeps only the redirects (www, HTTPS) and the pass-through to the CMS host, and the prerendered `dist/` goes to the CMS host's prerendered-pages folder as on test. Security headers then come from the CMS host (as on test). This is part of the production hosting work, not of the packages feature. Until then production builds use the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows a 404 for the API). Change generated server files only in `web/config/serverConfig.ts` and run `pnpm server-config`.
|
||||
- **Production: not in place yet.** The FTP upload (`web/deploy/upload-production.sh`) is FTPS (explicit TLS, no fallback) into the CMS host's prerendered-pages folder and no longer puts a `web.config` on the server (the host's own `web.config` comes from the CMS pipeline). The generated `web/deploy/iis/web.config` still describes the old idea of IIS serving the files and has to change with the production hosting: IIS keeps only the redirects (www, HTTPS) and the pass-through to the CMS host, and the prerendered `dist/` goes to the CMS host's prerendered-pages folder as on test. Security headers then come from the CMS host (as on test). This is part of the production hosting work, not of the packages feature. Until then production builds use the committed snapshot and the live calls fail safely (the baked list stays; the browser console shows a 404 for the API). Change generated server files only in `web/config/serverConfig.ts` and run `pnpm server-config`.
|
||||
- **Host injection (built in the site; the host side is the CMS repo's work):** the build leaves markers in the prerendered pages and the CMS host fills them from live data, so a CMS change is visible to search engines at once without a rebuild. Contract and plan: `aidlc-docs/features/asf-cms-host-injection/plan.md`; golden files for the list HTML: `web/contract/host-injection/`.
|
||||
- Markers: `<!--CMS:DATA-->` + `<script type="application/json" id="cms-data">` (root document, every page), `<!--CMS:OFFERINGS-HTML-->`, `<!--CMS:BANNER-TOP-HTML-->` and `<!--CMS:BANNER-BOTTOM-HTML-->` regions (home page), `<!--CMS:OFFER-JSON-LD slug="...">` before the ld+json block of the newborn, zwangerschap and gezin pages, and `<span data-cms-price="slug">` in their price block.
|
||||
- In the page: `CmsRegion` renders the plain HTML between the markers (`lib/cmsHtml.ts`, styled by `.cms-*` rules in `theme.ts`) and React leaves it alone until hydration, so a host that wrote different data causes no hydration mismatch; after hydration the styled components take over. `PackagesProvider` reads the data block in the first render after hydration (`hostCmsData`); a block with `"source":"build"` is the baked one and counts as "no host data", so the page asks the API as before. The site address comes from `siteUrl` in the block (`setSiteUrl` in `client.tsx`), because the script files cannot be rewritten per host.
|
||||
|
||||
@@ -66,13 +66,13 @@ Format `{ENV}_{GROUP}_{NAME}` with `ENV` = `TEST` or `PROD`, no app part (this r
|
||||
| `PROD_HEALTH_URL` | variable | `deploy-production`: check after the deploy |
|
||||
| `TEST_SENTRY_DSN`, `TEST_UMAMI_SCRIPT_URL`, `TEST_UMAMI_WEBSITE_ID` | variable | `build-test` and the CSP check in `deploy-test` (as `VITE_SENTRY_DSN`, `VITE_UMAMI_SCRIPT_URL`, `VITE_UMAMI_WEBSITE_ID`, `VITE_APP_ENV=test`) |
|
||||
| `PROD_SENTRY_DSN`, `PROD_UMAMI_SCRIPT_URL`, `PROD_UMAMI_WEBSITE_ID` | variable | `check` (the production artifact; `VITE_APP_ENV=production`) |
|
||||
| `PROD_HOST_ADDRESS`, `PROD_HOST_USERNAME`, `PROD_HOST_PASSWORD` | secrets | `deploy-production`: FTP (plain FTP, no FTPS, at the hosting partner) |
|
||||
| `PROD_HOST_ADDRESS`, `PROD_HOST_USERNAME`, `PROD_HOST_PASSWORD` | secrets | `deploy-production`: FTPS (explicit TLS) at the hosting partner |
|
||||
| `TEST_HOST_ADDRESS`, `TEST_HOST_PORT`, `TEST_HOST_USERNAME`, `TEST_HOST_SSH_KEY` | secrets | `deploy-test`: SSH key login to the Pi (one shared deploy key; no password) |
|
||||
|
||||
Removed: `PI_MAIN_*` (the SSH password login; the old secrets are deleted by Bryan after a green run), `DEPLOY_PATH_TEST`, `HEALTH_CHECK_URL_TEST`, `HEALTH_CHECK_URL_PRODUCTION`, `FTP_REMOTE_DIR`, `FTP_HOST`, `FTP_USERNAME`, `FTP_PASSWORD` (renamed), `ASF_OFFERINGS_URL_TEST` and `ASF_TEST_SERVED_BY_CMS` (no longer needed). The old names in the repo are removed by SLS after a green run.
|
||||
|
||||
**Monitoring per build.** Sentry and Umami settings are no longer in the code (`src/monitoring/config.ts`): every build gets them for its own environment and measures only on that environment's host (production build on `andreaslop.nl`, test build on `test.andreaslop.nl`; any other host measures nothing). The CSP origins for Umami and Sentry (`config/securityHeaders.ts`) come from the same variables, so a build without them has neither a measurement nor those origins; the build steps fail when a variable is empty. Unit and browser tests use the production values from `config/monitoringTestEnv.ts` (public values, the same as the variables); `pnpm server-config` does too, so the committed generated files carry the production CSP. The CMS host has its own copy of the origins in its environment (CMS repo).
|
||||
|
||||
## Plain FTP to production
|
||||
## FTPS to production
|
||||
|
||||
The production package only offers plain FTP, no FTPS or SFTP. `deploy/upload-production.sh` therefore never tries TLS (`ftp:ssl-allow no`, passive mode) and sends the user name, the password and the files unencrypted. Measures: a separate FTP account with rights only on the folder of the prerendered pages, a unique strong password that only exists as the secret `PROD_HOST_PASSWORD`, rotating it after the first rollout, and asking the host whether SFTP or explicit FTPS can be switched on. The script uploads in three rounds (everything except HTML, then all HTML, then cleaning up old files) into the prerendered-pages folder of the CMS host (`PROD_DEPLOY_PATH`, the exact folder is still open, see `aidlc-docs/features/asf-production-iis/plan.md`, A2). It does not put a `web.config` there and deletes nothing outside that folder; the host and its `web.config` come from the CMS pipeline. `PROD_HOST_PORT` is optional (default 21).
|
||||
The production package offers FTP over TLS. `deploy/upload-production.sh` forces explicit FTPS (`AUTH TLS`): `ftp:ssl-force yes`, `ftp:ssl-protect-data yes` and `ftp:ssl-protect-list yes`, so login, listings and files are encrypted, and the session refuses to fall back to plain FTP. The certificate of the server is checked (`ssl:verify-certificate yes`); if the host turns out to have a non-public certificate, record what is needed (the CA file) and ask Bryan before relaxing anything. The mode is passive. Use a separate FTP account with rights only on the folder of the prerendered pages and a unique strong password that only exists as the secret `PROD_HOST_PASSWORD`. The script uploads in three rounds (everything except HTML, then all HTML, then cleaning up old files) into the prerendered-pages folder of the CMS host (`PROD_DEPLOY_PATH`, the exact folder is still open, see `aidlc-docs/features/asf-production-iis/plan.md`, A2). It does not put a `web.config` there and deletes nothing outside that folder; the host and its `web.config` come from the CMS pipeline. `PROD_HOST_PORT` is optional (default 21). The tests (`e2e/deployScripts.e2e.ts`) check the lftp settings with a fake lftp and the upload with a local `file:` target; the real FTPS connection is tested by Bryan with the `PROD_HOST_*` secrets.
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
# De doelmap is de map met voorgerenderde pagina's van de CMS-host; de host
|
||||
# (en zijn web.config) staat er los van en wordt door de CMS-pijplijn gedeployd.
|
||||
# Verbinding: FTP_HOST, FTP_USER en LFTP_PASSWORD uit de omgeving, optioneel
|
||||
# FTP_PORT. Gewone FTP, geen FTPS: het productiepakket biedt alleen dat. De
|
||||
# gegevens gaan dus onversleuteld over het netwerk (zie docs/deploy-and-ci.md,
|
||||
# "Plain FTP"); daarom nooit TLS proberen en een eigen FTP-account met rechten
|
||||
# alleen op deze map.
|
||||
# FTP_PORT. Alleen FTP over TLS (FTPS, explicit: AUTH TLS): de inlog en de
|
||||
# bestanden gaan versleuteld, zonder terugval naar gewone FTP, en het
|
||||
# certificaat van de server wordt gecontroleerd (zie docs/deploy-and-ci.md,
|
||||
# "FTPS to production"). Gebruik een eigen FTP-account met rechten alleen op
|
||||
# deze map.
|
||||
# Alleen voor de test: LFTP_OPEN (bijvoorbeeld file:///) vervangt de
|
||||
# verbinding, en UPLOAD_PASS=1|2|3 voert maar één ronde uit.
|
||||
set -euo pipefail
|
||||
@@ -53,7 +54,10 @@ wants() { [ "$pass" = all ] || [ "$pass" = "$1" ]; }
|
||||
# Geen back-ups: lftp zet standaard een kopie met een tijdstempel
|
||||
# (web.config~20261101221045~) naast elk bestand dat het overschrijft. Op de
|
||||
# host zou elke deploy er een achterlaten, bereikbaar voor wie de naam raadt.
|
||||
settings="set ftp:ssl-allow no; set ftp:passive-mode on; set net:max-retries 3; set xfer:make-backup no;"
|
||||
# TLS: explicit FTPS afdwingen (de sessie weigert inloggen zonder TLS, ook de
|
||||
# datakanalen en de lijsten zijn versleuteld) en het certificaat controleren.
|
||||
tls="set ftp:ssl-allow yes; set ftp:ssl-auth TLS; set ftp:ssl-force yes; set ftp:ssl-protect-data yes; set ftp:ssl-protect-list yes; set ssl:verify-certificate yes;"
|
||||
settings="$tls set ftp:passive-mode on; set net:max-retries 3; set xfer:make-backup no;"
|
||||
|
||||
# Elke opdracht krijgt een eigen lftp-sessie, zodat het script bij een mislukte
|
||||
# ronde stopt (set -e) voordat de volgende ronde begint: de HTML gaat nooit
|
||||
@@ -70,7 +74,7 @@ run_lftp() {
|
||||
[[ "$FTP_PORT" =~ ^[0-9]+$ ]] || { echo "Ongeldige FTP_PORT" >&2; exit 2; }
|
||||
port=(-p "$FTP_PORT")
|
||||
fi
|
||||
lftp --env-password -u "$FTP_USER" "${port[@]}" "$FTP_HOST" -e "$commands"
|
||||
lftp --env-password -u "$FTP_USER" "${port[@]}" "ftp://$FTP_HOST" -e "$commands"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ touch '${slash(marker)}'
|
||||
},
|
||||
);
|
||||
|
||||
it('zet in elke lftp-sessie de back-ups uit en TLS uit (gewone FTP)', async () => {
|
||||
it('zet in elke lftp-sessie de back-ups uit en TLS aan zonder terugval (FTPS)', async () => {
|
||||
const dist = await makeDist();
|
||||
const bin = await makeTemp('andreaslop-fakebin-');
|
||||
const log = join(bin, 'opdrachten');
|
||||
@@ -694,9 +694,15 @@ printf '%s\\n' "$2" >> '${slash(log)}'
|
||||
expect(sessions).toHaveLength(3);
|
||||
for (const commands of sessions) {
|
||||
expect(commands).toContain('set xfer:make-backup no;');
|
||||
expect(commands).toContain('set ftp:ssl-allow no;');
|
||||
expect(commands).toContain('set ftp:ssl-allow yes;');
|
||||
expect(commands).toContain('set ftp:ssl-auth TLS;');
|
||||
expect(commands).toContain('set ftp:ssl-force yes;');
|
||||
expect(commands).toContain('set ftp:ssl-protect-data yes;');
|
||||
expect(commands).toContain('set ftp:ssl-protect-list yes;');
|
||||
expect(commands).toContain('set ssl:verify-certificate yes;');
|
||||
expect(commands).toContain('set ftp:passive-mode on;');
|
||||
expect(commands).not.toContain('ssl-force');
|
||||
expect(commands).not.toContain('ssl-allow no');
|
||||
expect(commands).not.toContain('verify-certificate no');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -736,7 +742,9 @@ printf '%s\n' "$*" >> '${slash(log)}'
|
||||
for (const line of (await readFile(log, 'utf8'))
|
||||
.split('\n')
|
||||
.filter(Boolean)) {
|
||||
expect(line).toContain('-u gebruiker -p 2121 ftp.example.test');
|
||||
expect(line).toContain(
|
||||
'-u gebruiker -p 2121 ftp://ftp.example.test',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user