Reputation: 31
I want to redirect a http post request to https post request.Is there a way to complete it through the proxy configuration in nginx. I find a blog in the http://nginx.com/blog/nginx-ssl/. And I have a try like this:
upstream backends {
server 192.168.100.100:443;
}
server {
listen 80;
server_name www.example.com;
location / {
proxy_pass https://backends;
}
}
But it returned a 502 bad gateway result when I curl it like this: curl -X POST 'http://www.example.com/a.json' --data-binary 'name=super'
Upvotes: 3
Views: 2841
Reputation: 33459
You need to use the 308 redirect instead of 301 (former keeps the method and latter mutates POSTs to GETs):
server {
listen 80;
server_name www.example.com;
return 308 https://$host$request_uri;
}
Upvotes: 3