0

Client - LB - App Server

I have an app that supports http or https. If the original request is https, but the server is expecting http, it won't work.

Is it possible to use nginx to rewrite the x-forwarded-for? The client requests https://x.x.x.x, but the server sees http://x.x.x.x

  • The X-Forwarded-For: header should contain IP addresses, not the protocol or the URL. Did you mean the X-Forwarded-Proto: header? Or something else entirely? – Ladadadada Jun 21 '13 at 15:43
  • I'm not sure. The app is detecting that the original request is https. The app will send a http redirect if it detects https. – Magd Jun 21 '13 at 16:09
  • This is in Amazon. I put the SSL cert on the Amazon ELB and discovered this issue. Therefore, I'm looking at haproxy/nginx to solve the issue. – Magd Jun 21 '13 at 16:10
  • Have you set your listeners in the ELB to send the SSL requests to SSL on the backend and the HTTP requests to HTTP on the backend? That's not the default configuration from memory. – Ladadadada Jun 21 '13 at 16:14
  • I need to load balance 443->80 and 80->80. 80 works, but 443 will redirect to 80. My app is receiving the traffic and knows it is not originally 80, then sends the http redirect. Therefore, I theorize that I need to alter the header before for server receives it. – Magd Jun 21 '13 at 16:29
1

The load balancer is "terminating" your SSL connection at that point, so all requests behind the LB will go in HTTP. The way to do this is to use nginx listening on SSL then proxy-pass the connection to your application.

  • Haproxy/nginx fixed my problem. I didn't need to configure X-Forwarded-Proto. – Magd Jun 25 '13 at 14:49

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.