Nginx 代理 - 来自上游的 return last-modified header
Nginx proxy - return last-modified header from upstream
我在使用 Nginx 作为代理服务器时遇到问题:
请求 -> NGINX 代理 -> 应用服务器(只有一个)
代理服务器在端口 443 上侦听,应用程序服务器在端口 80 上侦听。Headers return 由上游服务器编辑的内容正在被代理删除。我被迫使用:
add_header 'Content-Length' $upstream_http_content_length;
它适用于 Content-Length,但不适用于 Last-Modified header。来自 Nginx 代理的卷曲请求使用私有 IP 到上游 returns 所有 headers。为什么 Nginx 代理将此 header 删除,即使使用 add_header
指定了 return?
我有以下 nginx.conf 示例:
location /some-web-app {
proxy_pass http://backend/some-web-app;
proxy_redirect off;
proxy_redirect http $scheme;
proxy_set_header Host $host;
add_header 'Last-Modified' $upstream_http_last_modified;
add_header 'Content-Length' $upstream_http_content_length;
sub_filter 'codebase="http' 'codebase="https';
sub_filter_types application/x-java-jnlp-file;
access_log /var/log/nginx/some-web-app_access.log combined_jsession_upstream;
error_log /var/log/nginx/some-web-app_err.log;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
}
转发返回 last-modified header 在位置块中放置以下指令:
sub_filter_last_modified on
要转发任何其他 header,请使用 add_header
和 $upstream_http_${header}
。这里我转发Content-Lengthheader:
add_header 'Content-Length' $upstream_http_content_length;
我在使用 Nginx 作为代理服务器时遇到问题: 请求 -> NGINX 代理 -> 应用服务器(只有一个)
代理服务器在端口 443 上侦听,应用程序服务器在端口 80 上侦听。Headers return 由上游服务器编辑的内容正在被代理删除。我被迫使用:
add_header 'Content-Length' $upstream_http_content_length;
它适用于 Content-Length,但不适用于 Last-Modified header。来自 Nginx 代理的卷曲请求使用私有 IP 到上游 returns 所有 headers。为什么 Nginx 代理将此 header 删除,即使使用 add_header
指定了 return?
我有以下 nginx.conf 示例:
location /some-web-app {
proxy_pass http://backend/some-web-app;
proxy_redirect off;
proxy_redirect http $scheme;
proxy_set_header Host $host;
add_header 'Last-Modified' $upstream_http_last_modified;
add_header 'Content-Length' $upstream_http_content_length;
sub_filter 'codebase="http' 'codebase="https';
sub_filter_types application/x-java-jnlp-file;
access_log /var/log/nginx/some-web-app_access.log combined_jsession_upstream;
error_log /var/log/nginx/some-web-app_err.log;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
}
转发返回 last-modified header 在位置块中放置以下指令:
sub_filter_last_modified on
要转发任何其他 header,请使用 add_header
和 $upstream_http_${header}
。这里我转发Content-Lengthheader:
add_header 'Content-Length' $upstream_http_content_length;