zhuan: https://www.cnblogs.com/damaoa/p/13223921.html

 

问题描述:

  后台响应ResponseEntity时,Nginx将部分数据过滤了

 

原因:

官网说明:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version

By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed. If, on the contrary, the passing of fields needs to be permitted, the proxy_pass_header directive can be used.

默认情况下,nginx不会将头字段“Date”、“Server”、“X-Pad”和“X-Accel-…”从代理服务器的响应传递到客户端。proxy_hide_header指令设置不会传递的其他字段。相反,如果需要允许字段的传递,则可以使用proxy_pass_header指令。

 

 

 

 

 

 

 

 

 

 

 

解决办法:

 
proxy_http_version 默认为1.0,将 proxy_http_version 设置 1.1; 即可

location /api/ {
            proxy_http_version 1.1;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Nginx-Proxy true;
            proxy_set_header Connection "";
            proxy_pass  http://localhost:8099/;
        }

 

 
posted on 2024-12-26 16:55  lshan  阅读(34)  评论(0)    收藏  举报