One verifier, backend/app/services/captcha.py, and one widget, components/Captcha.jsx. There were two copies of each and they had drifted: the register widget loaded the script itself while the landing one relied on a page-level effect elsewhere in its file, and on the backend auth failed *open* on an unreachable Turnstile while contact failed *shut*. Both failure modes were kept rather than one quietly chosen, as an explicit `fail_open` argument with the reason written down: an outage that stops people creating accounts costs the site its users, while an outage that bounces a contact message costs the sender one retry. An unconfigured secret still skips verification entirely, as before, so a site with no keys keeps working. The keys in .env are empty. The Cloudflare ones there were live and are now dead, so **there is no captcha on register or contact until hCaptcha keys are issued** — this is not a state to leave a public site in. Also corrected on the way: docs/frontend.md still documented `login(email, password, turnstileToken)`, whose third argument had already gone from AuthContext. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TqXevQJhxFrM7jJg82cgZN
80 lines
3.2 KiB
Nginx Configuration File
80 lines
3.2 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript;
|
|
gzip_min_length 1024;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://hcaptcha.com https://*.hcaptcha.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https://hcaptcha.com https://*.hcaptcha.com; media-src 'self' blob:; connect-src 'self' https://hcaptcha.com https://*.hcaptcha.com; font-src 'self' https://fonts.gstatic.com; frame-src 'self' https://hcaptcha.com https://*.hcaptcha.com;" always;
|
|
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
|
|
|
# API proxy to backend
|
|
location /api/ {
|
|
resolver 127.0.0.11 valid=10s;
|
|
set $backend http://backend:8000;
|
|
proxy_pass $backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Large file uploads
|
|
client_max_body_size 500M;
|
|
proxy_request_buffering off;
|
|
proxy_read_timeout 600s;
|
|
}
|
|
|
|
# SCORM content — no frame-blocking headers, allow scripts
|
|
location /uploads/scorm/ {
|
|
resolver 127.0.0.11 valid=10s;
|
|
set $backend http://backend:8000;
|
|
proxy_pass $backend;
|
|
proxy_set_header Host $host;
|
|
proxy_hide_header X-Frame-Options;
|
|
proxy_force_ranges on; # Pinned backend FileResponse does not implement byte ranges.
|
|
# Local add_header prevents inheriting the app CSP; preserve backend SVG sandbox.
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
}
|
|
|
|
# Uploaded images proxy to backend
|
|
location /uploads/ {
|
|
resolver 127.0.0.11 valid=10s;
|
|
set $backend http://backend:8000;
|
|
proxy_pass $backend;
|
|
proxy_set_header Host $host;
|
|
# Backend owns private/no-store and Vary; never cache protected media.
|
|
proxy_force_ranges on;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
}
|
|
|
|
# Hashed build assets are immutable — a new build gets a new filename.
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
}
|
|
|
|
# index.html must never be cached, or a deploy keeps serving the old
|
|
# bundle references and the app appears unchanged after a release.
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, must-revalidate" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
}
|
|
|
|
# SPA fallback
|
|
location / {
|
|
add_header Cache-Control "no-cache, must-revalidate" always;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|