nginx: 405 not allowed问题解决

问题背景:

第三方跳转我方一个静态页面, 该页面在浏览器地址栏输入url链接后可以直接访问, 但对方系统跳转时nginx报405 not allowed

原因:

前后端分离项目, 前端采用nginx部署, nginx默认配置是不支持post请求静态资源的, 而对方跳转时采用的post请求, 所以nginx拦截报405

解决: 

静态server下的location加入 error_page 405 =200 $request_uri;

location / {
        root   /app/dorm/web/view/dist;
        index  index.html;
        try_files $uri $uri/ /index.html;
        error_page 405 =200  $request_uri;
    }

 

posted @ 2023-08-22 09:34  Sherlock先生  阅读(1197)  评论(0编辑  收藏  举报