Prepares the test site for the CMS host
The test route on the proxy Pi now points at the CMS host on port 5200. verify-deployment.sh gets a --cms mode that checks the exact security headers, caching, gzip only, a percent-encoded redirect, the 405 for POST, and the CMS routes. The deploy-test job uses it once the Gitea variable ASF_TEST_SERVED_BY_CMS is true. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// Schrijft de productie-CSP van de site naar stdout, zonder regeleinde. De
|
||||
// controle na deploy (deploy/verify-deployment.sh --cms) vergelijkt hiermee
|
||||
// de header van de CMS-host, zodat die niet van config/securityHeaders.ts
|
||||
// kan afwijken.
|
||||
|
||||
import { contentSecurityPolicy } from './securityHeaders.ts';
|
||||
|
||||
process.stdout.write(contentSecurityPolicy('production'));
|
||||
@@ -83,6 +83,20 @@ describe('serverconfiguratie', () => {
|
||||
expect(proxy).not.toContain('add_header');
|
||||
});
|
||||
|
||||
it('de proxy stuurt naar de CMS-host op poort 5200 met de forwarded headers', () => {
|
||||
// De CMS-host vertrouwt alleen de proxy-Pi (ForwardedHeaders:KnownProxies)
|
||||
// en haalt het bezoekersadres uit deze headers voor de rate limiter
|
||||
const proxy = nginxProxyConf();
|
||||
expect(proxy).toMatch(
|
||||
/^\s*proxy_pass http:\/\/192\.168\.1\.103:5200;/m,
|
||||
);
|
||||
expect(proxy).toContain(
|
||||
'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;',
|
||||
);
|
||||
expect(proxy).toContain('proxy_set_header X-Forwarded-Proto $scheme;');
|
||||
expect(proxy).toContain('proxy_set_header X-Real-IP $remote_addr;');
|
||||
});
|
||||
|
||||
it('proxy en testblok gebruiken dezelfde hostname', () => {
|
||||
// Alleen echte config-regels, geen commentaar
|
||||
const name = /^\s*server_name ([^;]+);/m;
|
||||
|
||||
@@ -292,23 +292,28 @@ ${block(' ', noCache)}
|
||||
|
||||
// nginx op de reverse-proxy-Pi (test): alleen HTTP. certbot voegt daarna
|
||||
// HTTPS en de redirect toe (certbot --nginx -d test.andreaslop.nl). Geen
|
||||
// security headers hier: die zet de hosting-Pi al, dubbel geeft dubbele headers.
|
||||
// Intern adres van de hosting-Pi (waar het testblok en WordPress draaien)
|
||||
// security headers hier: de CMS-host zet ze al, dubbel geeft dubbele headers.
|
||||
// Intern adres van de hosting-Pi (waar de CMS-host en WordPress draaien)
|
||||
const hostingPiAddress = '192.168.1.103';
|
||||
// Poort van de CMS-host Api.AndreaSlopFotografie (test) op de hosting-Pi. De
|
||||
// host serveert /admin, /api/v1 en de voorgerenderde site zelf; nginx op de
|
||||
// hosting-Pi (poort 80, andreaslop-test.conf) blijft als terugvaloptie staan.
|
||||
const cmsHostPort = 5200;
|
||||
|
||||
export function nginxProxyConf(): string {
|
||||
return `# ${generatedNotice}
|
||||
# Reverse proxy voor de testsite naar de hosting-Pi. certbot past dit bestand
|
||||
# aan voor HTTPS; kopieer het daarna dus niet opnieuw zonder certbot opnieuw te
|
||||
# draaien.
|
||||
# Reverse proxy voor de testsite naar de CMS-host op de hosting-Pi. certbot
|
||||
# past dit bestand aan voor HTTPS; kopieer het daarna dus niet opnieuw zonder
|
||||
# certbot opnieuw te draaien. Terugvallen op nginx van de hosting-Pi: haal
|
||||
# :${cmsHostPort} weg achter proxy_pass.
|
||||
server {
|
||||
listen 80;
|
||||
server_name test.andreaslop.nl;
|
||||
|
||||
location / {
|
||||
proxy_pass http://${hostingPiAddress};
|
||||
# Verplicht: de hosting-Pi kiest op basis van de hostname tussen het
|
||||
# testblok en WordPress
|
||||
proxy_pass http://${hostingPiAddress}:${cmsHostPort};
|
||||
# De CMS-host gebruikt Host niet om een site te kiezen, maar de
|
||||
# terugvaloptie (nginx op de hosting-Pi) wel: daarom blijft hij staan
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user