![nginx nginx](http://nginx.org/nginx.png)
引子
Nginx配置如下
server {
listen 80;
server_name www.xxx.com;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
proxy_pass http://127.0.0.1:8081;
root html;
index index.html index.htm;
.... ....
}
所遇情况
1. 通过HttpClient请求,就一直返回** 301 moved permanently **状态码。
2. 通过JS的ajax请求,有时候返回** 301**,有时候又正常, 并且我JS明明是** POST **请求,但是服务器打印出来的日志硬显示的是** GET **请求。
原因
浏览器请求服务器的时候,请求http地址,首先依旧是会获得到 301 状态码,但是浏览器会再次转换成 https 请求,但是这个过程中,会把 post 中的参数(即java中 inputStream())丢失
解决办法
没有更好的解决办法,直接请求https地址。。。
My Blog
blog.guijianpan.com