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