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'
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With