0
我有一個運行在端口8080上的Node.js應用程序,其中運行在前面的NGINX服務器並充當緩存反向代理。無法爲由NGINX反向代理緩存的內容設置HTTP標頭
我希望NGINX緩存everythnig,除了一個頁面,我的應用程序的dashbaord:/dashboard
。
這裏是我的配置至今:
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;
}
}
緩存似乎工作正常,但安全性頭(X-XSS-Protection
,Content-Security-Policy
等)似乎只增加/dashboard
,而不是像緩存頁面/
或/login
。
我的當前配置有什麼問題嗎?我能做些什麼來解決這個問題?
就是這樣。非常感謝你! – Bertrand