Nginx反向代理常见问题

1.页面展示HTTP 400错误

查看nginx.conf中upstream 后面名称配置是否包含下划线,有的话需要去掉或者改别的,因为新版本的nginx不能识别;

2.nginx代理websocket需要特殊的配置

 location / {
        client_max_body_size 100M;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;    #需要加入
        proxy_set_header Connection "upgrade";    #需要加入
        proxy_pass api.demoProject.com;
        proxy_set_header Origin "";   #如果出现403错误,需要加入
    }

3.nginx反向代理,跨域配置

add_header Access-Control-Allow-Origin *;  
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
发布了22 篇原创文章 · 获赞 12 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/benyuanone/article/details/91548715