首页 > 其他 > 详细

Nginx采坑日记(后台响应ResponseEntity时,Nginx将部分数据过滤)

时间:2020-07-02 12:51:32      阅读:76      评论:0      收藏:0      [点我收藏+]

 

执行流程:

技术分享图片

 

问题描述:

  后台响应ResponseEntity时,Nginx将部分数据过滤了,导致Vue提示如下图,但是实际上已经代理成功并返回数据了。

技术分享图片

 

原因:

官网说明: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;
        }

 

文章灵感来自:https://blog.csdn.net/sc9018181134/article/details/82055225

 

Nginx采坑日记(后台响应ResponseEntity时,Nginx将部分数据过滤)

原文:https://www.cnblogs.com/damaoa/p/13223921.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!