0

I'm using HAProxy 1.6

I'm forcing https usage. Therefore in my backend I'm redirecting http to https. For that I'm using the following code:

backend my-app-name
    redirect scheme https if !{ ssl_fc }
    [...]

This is working well but if my http request is done using POST Method it seems that redirect scheme will change the method to GET.

I saw that in the documentation of HAProxy concerning HTTP redirection we can change the HTTP code to 308. But I cannot change the behavior of my current application.

How can I redirect to https using HAProxy and keeping my original HTTP Method?

1

as you almost said, you could do the following:

backend my-app-name
       redirect scheme https code 308 if !{ ssl_fc }

haproxy will return 308 (instead of 302). I am not sure how your application is involved. If its sits behind haproxy it will never notice the first non-https requests. And for example, any browser will do a second request via https and the same HTTP verb, i.e. keeping the POST.

  • I'm not in position of testing it now has we manually changed our endpoints to https. In the use case I was describing, it was a Mobile App that was sitting behind haproxy trying to contact to an API. All the endpoints were hard coded inside the app pointing to "http". – maxime_039 Dec 15 '16 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.