nginx部署前端post请求405 not allowed问题解决
更新时间:2023年09月14日 09:10:52 作者:是杨杨呀
在配置前端项目的时候遇到了一个post请求405 not allowed,简单记录一下如何配置,这篇文章主要给大家介绍了关于nginx部署前端post请求405 not allowed问题解决方法,需要的朋友可以参考下
问题
第一次部署前端,将vue生成的dist 文件部署到nginx后,进入页面后post请求查询数据时,出现405 not allowed,经查阅发现,nginx 静态资源访问不支持post请求。
解决方案
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://192.168.3.129:8081$request_uri ; }
总结
到此这篇关于nginx部署前端post请求405 not allowed问题解决的文章就介绍到这了,更多相关nginx 405 not allowed内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Debian系统下为PHP程序配置Nginx服务器的基本教程
这篇文章主要介绍了Debian系统下为PHP程序配置Nginx服务器的基本教程,这里使用到了FastCGI和php-fpm,需要的朋友可以参考下2015-12-12Nginx结合Openresty通过Lua+Redis实现动态封禁IP
为了封禁某些爬虫或者恶意用户对服务器的请求,我们需要建立一个动态的 IP 黑名单,本文主要介绍了Nginx结合Openresty通过Lua+Redis实现动态封禁IP,感兴趣的可以了解一下2023-11-11
最新评论