前端nginx代理配置,并跳转接口,解决跨域问题

扶醉桌前 提交于 2021-01-06 17:59:05

server {
        listen       1888;
        server_name  localhost;
        root   project/dist;
        index  index.html index.htm;
        
      location /api {
            rewrite  ^.+api/?(.*)$ /$1 break;
            proxy_pass  http://172.16.10.202:8888/;    #node api server 即需要代理的IP地址
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         }

        location ~* .*\.gz$ {
        add_header Content-Encoding gzip;
        }
    }

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!