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

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;
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。