Ich habe eine Node.js-Anwendung, die auf Port 8080 läuft, mit einem NGINX-Server, der als Caching-Reverse-Proxy läuft.HTTP-Header für Inhalte, die von einem NGINX-Reverse-Proxy zwischengespeichert werden, können nicht festgelegt werden
Ich möchte, dass NGINX alle bis auf eine Seite im Dashboard meiner Anwendung zwischenspeichert: /dashboard
.
Hier ist meine Konfiguration so weit:
server {
listen 80;
server_name mydomain.name;
# SECURITY
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' https://gravatar.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; object-src 'none'";
...
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
location/{
add_header X-Proxy-Cache $upstream_cache_status;
proxy_cache STATIC;
proxy_pass http://127.0.0.1:8080;
}
location /dashboard {
proxy_pass http://127.0.0.1:8080/dashboard;
}
}
Caching in Ordnung zu sein scheint zu funktionieren, aber die Sicherheitsüberschriften (X-XSS-Protection
, Content-Security-Policy
, etc.) scheinen nur auf Seiten im Cache zu /dashboard
und nicht hinzugefügt werden wie /
oder /login
.
Ist etwas mit meiner aktuellen Konfiguration nicht in Ordnung? Was kann ich tun, um das Problem zu beheben?
Das war es. Vielen Dank! – Bertrand