nginx post请求返回403

编程入门 行业动态 更新时间:2024-10-15 04:20:59

<a href=https://www.elefans.com/category/jswz/34/1771256.html style=nginx post请求返回403"/>

nginx post请求返回403

nginx部署项目后,用户登录老是返回403,偶尔能登上去,点几个页面就又退出登录了,看了好久不知道什么问题。

后来突然想是不是登录时用的post的问题,改成get确实好用了。

搜了一圈发现添加这个跨域以后就好用了。记录一下以免以后再被坑

location / {root   html;index  index.html index.htm;proxy_pass http://tomcatserver;#这里以下是要添加的proxy_set_header host $host;proxy_set_header X-forwarded-for $proxy_add_x_forwarded_for;proxy_set_header X-real-ip $remote_addr;#在TOMCAT配置CORS不太容易 所以在NGINX进行配置,这样就不需要在TOMCAT进行配置#参加跨域支持 Allow-Origin用*有时候不行add_header Access-Control-Allow-Origin  $http_origin;add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';add_header Access-Control-Allow-Credentials 'true';add_header Access-Control-Allow-Headers 'X-Requested-With,Accept, Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';if ($request_method = 'OPTIONS') {add_header 'Access-Control-Max-Age' 1728000;add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, OPTIONS';add_header 'Access-Control-Allow-Headers' 'Accept, Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';add_header 'Content-Type' 'text/plain charset=UTF-8';add_header 'Content-Length' 0;return 204;}}

更多推荐

nginx post请求返回403

本文发布于:2024-03-11 23:46:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1730210.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:nginx   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!