Plain map keys compare case-insensitively, so /Over-Mij was not redirected. A path starting with an encoded backslash could become an open redirect through the trailing-slash rule; it now gets the 404 page. Also makes the tests readable for nginx's workers and less sensitive to the slow CI runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
169 lines
9.8 KiB
Plaintext
169 lines
9.8 KiB
Plaintext
# Gegenereerd door web/config/serverConfig.ts (pnpm server-config). Niet handmatig aanpassen.
|
|
# 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;
|
|
|
|
# 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;
|
|
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;
|
|
|
|
# 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;
|
|
|
|
# Een backslash vooraan zou na het weghalen van de slashes een Location
|
|
# /\host geven, en browsers lezen dat als //host. Dat pad bestaat niet
|
|
# (BR-HST-06). \x5c is de backslash; $uri is hier al gedecodeerd.
|
|
if ($uri ~ "^/\x5c") {
|
|
return 404;
|
|
}
|
|
|
|
# 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;
|
|
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;
|
|
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;
|
|
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 "public, max-age=31536000, immutable" always;
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# 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;
|
|
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 $uri $uri.html =404;
|
|
}
|
|
}
|