Adds the URL rules to the preview server, IIS config and deploy
The preview server and web.config now follow the same URLs as nginx, without the SPA fallback. Lighthouse exceptions need a recorded reason and the 404 page is audited through an opt-in route. The deploy checks the build first and the served result afterwards. The IIS rules stay unverified until a host exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Controle van de build voordat die wordt geüpload (BR-HST-15, FR-PR-17).
|
||||
# Gebruik: check-artifact.sh <dist-map>
|
||||
# Faalt als een verplicht bestand ontbreekt, als de servermap erin zit, of als
|
||||
# er een source map in staat (die zou de broncode openbaar maken).
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Gebruik: $0 <dist-map>" >&2
|
||||
exit 2
|
||||
fi
|
||||
dist="$1"
|
||||
|
||||
if [ ! -d "$dist" ]; then
|
||||
echo "Geen map: $dist" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
failures=0
|
||||
fail() {
|
||||
echo "FOUT: $1" >&2
|
||||
failures=$((failures + 1))
|
||||
}
|
||||
|
||||
for file in index.html 404.html over-mij.html; do
|
||||
if [ -f "$dist/$file" ]; then
|
||||
echo "gevonden: $file"
|
||||
else
|
||||
fail "$file ontbreekt in $dist"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -e "$dist/server" ]; then
|
||||
fail "$dist/server bestaat: alleen de clientmap hoort online"
|
||||
fi
|
||||
|
||||
maps="$(find "$dist" -type f -name '*.map')"
|
||||
if [ -n "$maps" ]; then
|
||||
fail "source maps gevonden:
|
||||
$maps"
|
||||
fi
|
||||
|
||||
if [ "$failures" -gt 0 ]; then
|
||||
echo "Build geweigerd ($failures fout(en))" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Build in orde: $dist"
|
||||
@@ -18,16 +18,46 @@
|
||||
</conditions>
|
||||
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
|
||||
</rule>
|
||||
<rule name="SPA fallback" stopProcessing="true">
|
||||
<match url=".*" />
|
||||
<conditions logicalGrouping="MatchAll">
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
|
||||
<rule name="Index naar root" stopProcessing="true">
|
||||
<match url="^index(?:\.html)?/*$" />
|
||||
<action type="Redirect" url="/" redirectType="Permanent" />
|
||||
</rule>
|
||||
<rule name="Pagina canoniek" stopProcessing="true">
|
||||
<match url="^(over-mij|portfolio|soorten-fotoshoots|soorten-fotoshoots/newborn|soorten-fotoshoots/zwangerschap|soorten-fotoshoots/gezin|soorten-fotoshoots/loveshoot|soorten-fotoshoots/portret|contact|privacyverklaring)(?:\.html)?/*$" />
|
||||
<conditions>
|
||||
<add input="{R:0}" pattern="^(?:over-mij|portfolio|soorten-fotoshoots|soorten-fotoshoots/newborn|soorten-fotoshoots/zwangerschap|soorten-fotoshoots/gezin|soorten-fotoshoots/loveshoot|soorten-fotoshoots/portret|contact|privacyverklaring)$" ignoreCase="false" negate="true" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="/index.html" />
|
||||
<action type="Redirect" url="/{ToLower:{R:1}}" redirectType="Permanent" />
|
||||
</rule>
|
||||
<rule name="Slash weg" stopProcessing="true">
|
||||
<match url="^([^/\\].*?)/+$" />
|
||||
<action type="Redirect" url="/{R:1}" redirectType="Permanent" />
|
||||
</rule>
|
||||
<rule name="404 direct" stopProcessing="true">
|
||||
<match url="^404(?:\.html)?$" />
|
||||
<action type="CustomResponse" statusCode="404" statusReason="Not Found" statusDescription="Not Found" />
|
||||
</rule>
|
||||
<rule name="Pagina bestand" stopProcessing="true">
|
||||
<match url="^(.+)$" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_FILENAME}.html" matchType="IsFile" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="{R:1}.html" />
|
||||
</rule>
|
||||
<rule name="Map zonder pagina" stopProcessing="true">
|
||||
<match url="^(.+)$" />
|
||||
<conditions>
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
|
||||
</conditions>
|
||||
<action type="CustomResponse" statusCode="404" statusReason="Not Found" statusDescription="Not Found" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
<httpErrors errorMode="Custom" existingResponse="Replace">
|
||||
<remove statusCode="404" subStatusCode="-1" />
|
||||
<error statusCode="404" subStatusCode="-1" path="/404.html" responseMode="ExecuteURL" />
|
||||
</httpErrors>
|
||||
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="X-Powered-By" />
|
||||
@@ -41,6 +71,14 @@
|
||||
<staticContent>
|
||||
<remove fileExtension=".woff2" />
|
||||
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
|
||||
<remove fileExtension=".js" />
|
||||
<mimeMap fileExtension=".js" mimeType="text/javascript" />
|
||||
<remove fileExtension=".svg" />
|
||||
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
|
||||
<remove fileExtension=".json" />
|
||||
<mimeMap fileExtension=".json" mimeType="application/json" />
|
||||
<remove fileExtension=".xml" />
|
||||
<mimeMap fileExtension=".xml" mimeType="text/xml" />
|
||||
<clientCache cacheControlMode="DisableCache" />
|
||||
</staticContent>
|
||||
</system.webServer>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# Upload naar productie in drie rondes (BR-HST-14, 15; FR-PR-18).
|
||||
# Gebruik: upload-production.sh <dist-map> <doelmap-op-de-server>
|
||||
# Verbinding: FTP_HOST, FTP_USER en LFTP_PASSWORD uit de omgeving (FTPS).
|
||||
# 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
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Gebruik: $0 <dist-map> <doelmap>" >&2
|
||||
exit 2
|
||||
fi
|
||||
dist="${1%/}"
|
||||
remote="${2%/}"
|
||||
|
||||
# De paden komen in een lftp-opdracht; daarom geen spaties of quotes
|
||||
safe='^[A-Za-z0-9._/-]+$'
|
||||
for value in "$dist" "$remote"; do
|
||||
if ! [[ "$value" =~ $safe ]]; then
|
||||
echo "Ongeldig pad: '$value'" >&2
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
bash "$here/check-artifact.sh" "$dist"
|
||||
cp "$here/iis/web.config" "$dist/web.config"
|
||||
|
||||
pass="${UPLOAD_PASS:-all}"
|
||||
case "$pass" in
|
||||
all | 1 | 2 | 3) ;;
|
||||
*) echo "Ongeldige UPLOAD_PASS: '$pass'" >&2; exit 2 ;;
|
||||
esac
|
||||
wants() { [ "$pass" = all ] || [ "$pass" = "$1" ]; }
|
||||
|
||||
commands="set ftp:ssl-force true; set ftp:ssl-protect-data true; set net:max-retries 3;"
|
||||
# Ronde 1: alles behalve HTML en web.config, dus ook /assets. Nieuwe
|
||||
# bestanden met hash in de naam storen de oude release niet.
|
||||
if wants 1; then
|
||||
commands="$commands mirror --reverse --verbose --exclude-glob '*.html' --exclude-glob web.config $dist/ $remote/;"
|
||||
fi
|
||||
# Ronde 2: web.config vlak voor de HTML (de regels passen bij de nieuwe
|
||||
# bestanden), dan alle HTML, ook de geneste pagina's en 404.html. Pas nu
|
||||
# verwijst iets naar de nieuwe assets.
|
||||
if wants 2; then
|
||||
commands="$commands put -O $remote $dist/web.config;"
|
||||
commands="$commands mirror --reverse --verbose --include-glob '*.html' $dist/ $remote/;"
|
||||
fi
|
||||
# Ronde 3: opruimen als laatste, zodat bezoekers met de oude HTML hun oude
|
||||
# assets nog vinden tot de nieuwe HTML helemaal staat.
|
||||
if wants 3; then
|
||||
commands="$commands mirror --reverse --delete --verbose $dist/ $remote/;"
|
||||
fi
|
||||
commands="$commands quit"
|
||||
|
||||
if [ -n "${LFTP_OPEN:-}" ]; then
|
||||
lftp -e "$commands" "$LFTP_OPEN"
|
||||
else
|
||||
: "${FTP_HOST:?FTP_HOST ontbreekt}" "${FTP_USER:?FTP_USER ontbreekt}"
|
||||
: "${LFTP_PASSWORD:?LFTP_PASSWORD ontbreekt}"
|
||||
lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e "$commands"
|
||||
fi
|
||||
@@ -0,0 +1,152 @@
|
||||
#!/usr/bin/env bash
|
||||
# Controle na een deploy (BR-HST-18): wat de server teruggeeft moet gelijk zijn
|
||||
# aan wat in dist staat. Een oude nginx-config die voor elk pad de homepage
|
||||
# geeft (SPA-fallback) valt hier door de mand.
|
||||
# Gebruik: verify-deployment.sh <basis-url> <dist-map> [--test]
|
||||
# --test: ook X-Robots-Tag, en gzip op de JavaScript is verplicht
|
||||
# (zonder --test geeft ontbrekende gzip alleen een waarschuwing)
|
||||
set -euo pipefail
|
||||
|
||||
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
|
||||
echo "Gebruik: $0 <basis-url> <dist-map> [--test]" >&2
|
||||
exit 2
|
||||
fi
|
||||
base="$1"
|
||||
dist="$2"
|
||||
test_mode=0
|
||||
if [ "$#" -eq 3 ]; then
|
||||
if [ "$3" != "--test" ]; then
|
||||
echo "Onbekende optie: $3" >&2
|
||||
exit 2
|
||||
fi
|
||||
test_mode=1
|
||||
fi
|
||||
|
||||
if ! [[ "$base" =~ ^https?://[^[:space:]]+$ ]]; then
|
||||
echo "Ongeldige URL: '$base'" >&2
|
||||
exit 2
|
||||
fi
|
||||
while [[ "$base" == */ ]]; do base="${base%/}"; done
|
||||
if [ ! -d "$dist" ]; then
|
||||
echo "Geen map: $dist" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
failures=0
|
||||
fail() {
|
||||
echo "FOUT: $1" >&2
|
||||
failures=$((failures + 1))
|
||||
}
|
||||
|
||||
# Haalt $base$1 op zonder redirects te volgen en zonder Accept-Encoding
|
||||
# (curl stuurt er zelf geen). Bewaart status, headers en body in $work.
|
||||
# Meer argumenten: extra curl-opties (bijvoorbeeld een header).
|
||||
fetch() {
|
||||
local path="$1"
|
||||
shift
|
||||
: > "$work/headers"
|
||||
: > "$work/body"
|
||||
status="$(curl -sS --max-time 30 -o "$work/body" -D "$work/headers" \
|
||||
-w '%{http_code}' "$@" "$base$path")"
|
||||
}
|
||||
|
||||
# Waarde van een header uit de laatst opgehaalde respons (hoofdletterongevoelig)
|
||||
header() {
|
||||
tr -d '\r' < "$work/headers" | grep -i "^$1:" | head -n 1 | cut -d: -f2- | sed 's/^[[:space:]]*//' || true
|
||||
}
|
||||
|
||||
check_security_headers() {
|
||||
local label="$1" name
|
||||
local names=(Content-Security-Policy Strict-Transport-Security X-Content-Type-Options X-Frame-Options Referrer-Policy)
|
||||
if [ "$test_mode" -eq 1 ]; then names+=(X-Robots-Tag); fi
|
||||
for name in "${names[@]}"; do
|
||||
if [ -z "$(header "$name")" ]; then
|
||||
fail "$label: header $name ontbreekt"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Een 200 met de bytes van het verwachte bestand uit dist
|
||||
expect_file() {
|
||||
local path="$1" file="$2"
|
||||
fetch "$path"
|
||||
if [ "$status" != "200" ]; then
|
||||
fail "$path: status $status, verwacht 200"
|
||||
elif ! cmp -s "$work/body" "$dist/$file"; then
|
||||
fail "$path: antwoord is niet gelijk aan $file uit dist (oude serverconfig of oude build?)"
|
||||
fi
|
||||
check_security_headers "$path"
|
||||
}
|
||||
|
||||
# Een 301 naar een pad (Location mag absoluut of relatief zijn)
|
||||
expect_redirect() {
|
||||
local path="$1" target="$2" location
|
||||
fetch "$path"
|
||||
if [ "$status" != "301" ]; then
|
||||
fail "$path: status $status, verwacht 301"
|
||||
else
|
||||
location="$(header Location)"
|
||||
location="${location#http://*/}"
|
||||
location="${location#https://*/}"
|
||||
if [[ "$location" != /* ]]; then location="/$location"; fi
|
||||
if [ "$location" != "$target" ]; then
|
||||
fail "$path: Location '$(header Location)', verwacht pad $target"
|
||||
fi
|
||||
fi
|
||||
check_security_headers "$path"
|
||||
}
|
||||
|
||||
for file in index.html over-mij.html soorten-fotoshoots/newborn.html 404.html; do
|
||||
if [ ! -f "$dist/$file" ]; then
|
||||
echo "Geen $file in $dist" >&2
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
# De server moet bereikbaar zijn; kort herhalen zoals de oude controle
|
||||
if ! curl -sS --retry 5 --retry-delay 3 --retry-connrefused --max-time 30 \
|
||||
-o /dev/null "$base/"; then
|
||||
echo "Niet bereikbaar: $base/" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
expect_file / index.html
|
||||
expect_file /over-mij over-mij.html
|
||||
expect_file /soorten-fotoshoots/newborn soorten-fotoshoots/newborn.html
|
||||
|
||||
fetch /onbekend-pad-voor-controle
|
||||
if [ "$status" != "404" ]; then
|
||||
fail "/onbekend-pad-voor-controle: status $status, verwacht 404"
|
||||
elif ! cmp -s "$work/body" "$dist/404.html"; then
|
||||
fail "/onbekend-pad-voor-controle: antwoord is niet gelijk aan 404.html uit dist"
|
||||
fi
|
||||
check_security_headers /onbekend-pad-voor-controle
|
||||
|
||||
expect_redirect /over-mij/ /over-mij
|
||||
expect_redirect /Over-Mij /over-mij
|
||||
|
||||
# Compressie van de JavaScript uit index.html
|
||||
script="$(grep -o '/assets/[A-Za-z0-9_./-]*\.js' "$dist/index.html" | head -n 1 || true)"
|
||||
if [ -z "$script" ]; then
|
||||
fail "geen /assets/*.js gevonden in index.html om de compressie te controleren"
|
||||
else
|
||||
fetch "$script" -H 'Accept-Encoding: gzip'
|
||||
if [ "$status" != "200" ]; then
|
||||
fail "$script: status $status, verwacht 200"
|
||||
elif [ "$(header Content-Encoding)" != "gzip" ]; then
|
||||
if [ "$test_mode" -eq 1 ]; then
|
||||
fail "$script: geen Content-Encoding: gzip"
|
||||
else
|
||||
echo "WAARSCHUWING: $script wordt niet gecomprimeerd (de webhost beslist)" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$failures" -gt 0 ]; then
|
||||
echo "Controle mislukt ($failures fout(en)) voor $base" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Controle geslaagd voor $base"
|
||||
Reference in New Issue
Block a user