如果后端真是的服务器设置有类似防盗链或者根据http请求头中的host字段来进行路由或判断功能的话
    ,如果反向代理层的nginx不重写请求头中的host字段,将会导致请求失败,报400错误,
    解决办法:
    location中设置
    proxy_set_header Host $http_host;
    [root@nignx ~]#vim /usr/local/nginx/conf/nginx.conf

    1. server {
    2. listen 80;
    3. server_name localhost;
    4. charset utf-8;
    5. access_log logs/host.access.log main;
    6. location / {
    7. root html;
    8. index index.html index.htm;
    9. proxy_set_header Host $http_host; //此处要添加host头,将头信息返回服务器
    10. }

    转自:
    https://www.cnblogs.com/CMX_Shmily/p/11582558.html