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
发布评论