当前位置:首页 » 《休闲阅读》 » 正文

解决nginx 部署前端post请求405 not allowed

16 人参与  2024年03月26日 13:25  分类 : 《休闲阅读》  评论

点击全文阅读


原因:nginx 静态资源访问不支持post请求。

解决方案:

       upstream static_backend {            server localhost:9095;       }       location / {            root  /usr/local/dist;            try_files $uri $uri/ /index.html;            index  index.html index.htm;            error_page 405 =200 @405;  #405页面处理       }        #加入下面代码       location @405 {             proxy_set_header Host $host;              proxy_set_header X-Real-IP $remote_addr;             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;               #ip为后端服务地址             proxy_pass http://localhost:9095$request_uri ;       }

或者

location / {        root /usr/share/nginx/html/cashier;        try_files $uri $uri/ /index.html;        index index.html index.htm;        error_page 405 =200  $request_uri; // $request_uri这个参数的含义下面有解释}


点击全文阅读


本文链接:http://zhangshiyu.com/post/85855.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1