0

I redirect all of the requests to HTTPS with this snippet:

server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;

}

The problem is that I can not send a POST request to my server thru Nginx because it redirects to a GET request.

I use NodeJS and Express.

  • The POST is already insecure, you need to make it to https to start with. There's some discussion here: https://stackoverflow.com/q/39280361/3001761. – jonrsharpe May 26 '18 at 20:47
  • https://serverfault.com/questions/312111/how-do-i-get-nginx-to-forward-http-post-requests-via-rewrite – NobbyNobbs May 26 '18 at 20:48
  • 2
    Why do you send post request via http if your server use https? – NobbyNobbs May 26 '18 at 20:49
  • Possible duplicate of [Nginx loses POST variable with http -> https redirect](https://stackoverflow.com/questions/39280361/nginx-loses-post-variable-with-http-https-redirect) – Richard Smith May 27 '18 at 08:52

1 Answers1

0

If you are willing to forget the "permanent" redirect status, I believe a 307 redirect instead of a 301 will preserve the POST.

thatcoder
  • 367
  • 2
  • 9