Dak*_*ser 7 nginx cache http-headers
我在尝试让 Nginx 忽略并隐藏代理服务器的一些标头时遇到了麻烦。
我希望 Nginx 隐藏并忽略“Cache-Control”和“Server”标头,但它不起作用,我不知道为什么。
我的配置如下:
location / {
proxy_pass http://111.131.50.42;
proxy_hide_header Cache-Control;
expires 60M;
add_header Cache-Control "public";
proxy_ignore_headers Cache-Control;
proxy_hide_header Cache-Control;
access_log off;
}
Run Code Online (Sandbox Code Playgroud)
但即便如此,我仍然收到原始“Cache-Control”和“Server”标头。
你知道我做错了什么吗?
PS 我不能使用 ngx_headers_more 模块。我无法将此模块添加到我们的 Nginx 安装中。
Xav*_*cas 12
指令proxy_ignore_headers
告诉 nginx 忽略导致特定内部行为的特殊标头的内容:
“X-Accel-Expires”、“Expires”、“Cache-Control”、“Set-Cookie”、“Vary”设置响应缓存的参数;
“X-Accel-Redirect”执行到指定URI的内部重定向;
“X-Accel-Limit-Rate”设置传输响应给客户端的速率限制;
“X-Accel-Buffering” 启用或禁用响应缓冲;
“X-Accel-Charset”设置响应的所需字符集。
如果要隐藏上游服务器的标头,则需要使用proxy_hide_header
. 所述Server
报头不传递到默认发送到客户端的响应,如Date
,X-Pad
和X-Accel-...
标头。
所以,这应该工作:
location / {
access_log off;
add_header Cache-Control "public";
proxy_pass http://111.131.50.42;
proxy_hide_header Cache-Control;
expires 60M;
}
Run Code Online (Sandbox Code Playgroud)
确保您没有使用已经缓存数据的浏览器进行测试,请使用curl
.
归档时间: |
|
查看次数: |
27205 次 |
最近记录: |