服务端配置https证书后post请求变成get请求问题

2021-05-16  本文已影响0人  天天想念

https现在越来越流行,前几天将部署的网站请求http配置成了https后,发现提供给前端接口所有的post请求变成了get请求。提示如下错误(使用springboot脚手架):

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported

经过查询,我的解决方案是修改Nginx的配置

修改前
server {
        listen 80;
        server_name yourdomain.com; 
        rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。
        location / {
            index index.html index.htm;
        }
    }
修改后
server {
        listen 80;
        server_name yourdomain.com; 
        return 307 https://$host$request_uri;
        location / {
            index index.html index.htm;
        }
    }
上一篇 下一篇

猜你喜欢

热点阅读