zoukankan      html  css  js  c++  java
  • Nginx采坑日记(后台响应ResponseEntity时,Nginx将部分数据过滤)

     

    执行流程:

    问题描述:

      后台响应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
  • 相关阅读:
    1167E (尺取法)
    Report CodeForces
    Maximum Xor Secondary CodeForces
    Sliding Window POJ
    单调队列 Sliding Window POJ
    尺取法
    目标
    NOIP系列(续)
    NOIP系列
    近期目标
  • 原文地址:https://www.cnblogs.com/damaoa/p/13223921.html
Copyright © 2011-2022 走看看