Answer the question
In order to leave comments, you need to log in
How to redirect a request from http to https through nginx so that post requests work correctly?
Comrades, please tell me about this question:
If there is a site, 2 versions are working now - Http and Https.
There is an application which works only on Http. The application sends post requests to the site.
If I include a 301 redirect from http to https, then post requests break, as the request method changes from POST to GET.
I tried to include a 307 redirect, which, according to the specification https://tools.ietf.org/html/rfc7231#section-6.4.7
, should not change the request method, but the application does not know the 307 redirect.
Here, accordingly, the question is, are there any other possibilities from the nginx config to ensure both the redirect and the work of POST requests?
Answer the question
In order to leave comments, you need to log in
Sending a POST request over HTTP and then redirecting it over HTTPS seems pointless. You have already sent data using an insecure protocol. I understand that it is impossible to make changes to the application quickly. Therefore, I suggest you check that the request came from the application and do not redirect or disable redirection for POST requests.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question