Generates the nginx rules for prerendered pages
Pages now map to their html file, other forms get one redirect, unknown URLs get a real 404 and responses are compressed. A browser-free test suite runs the rules against a real nginx, in CI only so far. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,20 +1,58 @@
|
||||
# Gegenereerd door web/config/serverConfig.ts (pnpm server-config). Niet handmatig aanpassen.
|
||||
# Test-omgeving op de Raspberry Pi, achter de reverse-proxy-Pi (die TLS afhandelt
|
||||
# met certbot). De proxy moet de Host-header doorgeven (proxy_set_header Host
|
||||
# $host), anders kiest nginx hier het standaardblok (WordPress).
|
||||
# Test-omgeving op de Raspberry Pi (hosting-Pi), achter de reverse-proxy-Pi
|
||||
# (die TLS afhandelt met certbot). Installatie: als
|
||||
# /etc/nginx/conf.d/andreaslop-test.conf; nginx.conf laadt conf.d binnen
|
||||
# http {}, er is geen sites-enabled. De globale nginx.conf hoeft niet te
|
||||
# veranderen: dit bestand brengt zijn eigen gzip-instellingen mee, want op de
|
||||
# Pi staat gzip nergens aan. Ze werken ook als de proxy HTTP/1.0 praat.
|
||||
# De proxy moet de Host-header doorgeven (proxy_set_header Host $host); het
|
||||
# blok wordt gekozen op server_name. Een onbekende host krijgt een 444 van
|
||||
# het standaardblok /etc/nginx/conf.d/00-default.conf.
|
||||
# Eigen server-blok naast de WordPress-site: bewust geen default_server, zodat
|
||||
# dit blok alleen de testhostname beantwoordt.
|
||||
# Pas server_name en root aan aan de server; de rest komt uit de generator.
|
||||
|
||||
# Bekende pagina's in een afwijkende vorm (hoofdletters, .html, /index,
|
||||
# slashes aan het eind) gaan met één 301 naar het canonieke pad. De waarden
|
||||
# zijn constanten uit de paginalijst, nooit afgeleid van het verzoek.
|
||||
map $uri $andreaslop_canonical {
|
||||
default "";
|
||||
/over-mij "";
|
||||
/portfolio "";
|
||||
/soorten-fotoshoots "";
|
||||
/soorten-fotoshoots/newborn "";
|
||||
/soorten-fotoshoots/zwangerschap "";
|
||||
/soorten-fotoshoots/gezin "";
|
||||
/soorten-fotoshoots/loveshoot "";
|
||||
/soorten-fotoshoots/portret "";
|
||||
/contact "";
|
||||
/privacyverklaring "";
|
||||
~*^/index(?:\.html)?/*$ /;
|
||||
~*^/over-mij(?:\.html)?/*$ /over-mij;
|
||||
~*^/portfolio(?:\.html)?/*$ /portfolio;
|
||||
~*^/soorten-fotoshoots(?:\.html)?/*$ /soorten-fotoshoots;
|
||||
~*^/soorten-fotoshoots/newborn(?:\.html)?/*$ /soorten-fotoshoots/newborn;
|
||||
~*^/soorten-fotoshoots/zwangerschap(?:\.html)?/*$ /soorten-fotoshoots/zwangerschap;
|
||||
~*^/soorten-fotoshoots/gezin(?:\.html)?/*$ /soorten-fotoshoots/gezin;
|
||||
~*^/soorten-fotoshoots/loveshoot(?:\.html)?/*$ /soorten-fotoshoots/loveshoot;
|
||||
~*^/soorten-fotoshoots/portret(?:\.html)?/*$ /soorten-fotoshoots/portret;
|
||||
~*^/contact(?:\.html)?/*$ /contact;
|
||||
~*^/privacyverklaring(?:\.html)?/*$ /privacyverklaring;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name test.andreaslop.nl;
|
||||
root /var/www/html/andreaslop-test;
|
||||
index index.html;
|
||||
|
||||
# Achter de reverse proxy: doorverwijzingen relatief houden, anders stuurt
|
||||
# nginx naar zijn eigen http://-adres in plaats van de https-hostname
|
||||
absolute_redirect off;
|
||||
|
||||
# Geen index-directive en geen mappen tonen: index zou intern naar
|
||||
# /index.html gaan, dat hierboven naar / doorverwijst (lus)
|
||||
autoindex off;
|
||||
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
@@ -23,6 +61,28 @@ server {
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
|
||||
# Eigen compressie (de Pi heeft geen gzip aan). text/html is altijd aan.
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_http_version 1.0;
|
||||
gzip_comp_level 5;
|
||||
gzip_min_length 256;
|
||||
gzip_types text/javascript application/javascript text/css image/svg+xml application/json text/xml application/xml text/plain;
|
||||
|
||||
# Alleen return in een if is veilig. Het doel komt uit de map hierboven.
|
||||
if ($andreaslop_canonical) {
|
||||
return 301 $andreaslop_canonical$is_args$args;
|
||||
}
|
||||
|
||||
# Slashes aan het eind van elk ander pad weg. Bewust rewrite en geen
|
||||
# return met $uri: de serverregeltests controleren dat een regeleinde of
|
||||
# backslash in het pad nooit in een Location terechtkomt.
|
||||
rewrite ^/(.+?)/+$ /$1 permanent;
|
||||
|
||||
# Onbekend: de 404-pagina met status 404 (geen = achter de code)
|
||||
error_page 404 /404.html;
|
||||
|
||||
# Testsite nooit indexeren
|
||||
location = /robots.txt {
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
@@ -31,10 +91,35 @@ server {
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
default_type text/plain;
|
||||
return 200 "User-agent: *\nDisallow: /\n";
|
||||
}
|
||||
|
||||
# Zonder dit zou $uri.html de pagina met 200 tonen
|
||||
location = /404 {
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Alleen bereikbaar via error_page; een direct verzoek geeft 404
|
||||
location = /404.html {
|
||||
internal;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
}
|
||||
|
||||
# Bestanden met een hash in de naam: lang cachen
|
||||
location /assets/ {
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
@@ -47,9 +132,22 @@ server {
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# SPA-fallback: onbekende paden krijgen index.html (de router toont de 404).
|
||||
# =404 aan het eind: zonder index.html (lege map) een 404 in plaats van een
|
||||
# doorverwijzingslus die nginx als 500 afbreekt
|
||||
# Geen index-directive: de beginpagina staat hier uitdrukkelijk
|
||||
location = / {
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
try_files /index.html =404;
|
||||
}
|
||||
|
||||
# Paginabestand zonder .html. $uri zonder slash is alleen een bestand, dus
|
||||
# een map naast soorten-fotoshoots.html wordt overgeslagen (BR-HST-07).
|
||||
# Nooit een slash achter de variabele zetten: dat geeft nginx' eigen
|
||||
# mapdoorverwijzing.
|
||||
location / {
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://analytics.slpsoftware.nl; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.slpsoftware.nl https://o4511795618185216.ingest.de.sentry.io; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
@@ -58,6 +156,6 @@ server {
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header Cache-Control "no-cache" always;
|
||||
try_files $uri $uri/ /index.html =404;
|
||||
try_files $uri $uri.html =404;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user