I'm looking to redirect from HTTP to HTTPS. My Nginx server sits behind a load balancer which will terminate SSL for me and send all traffic (HTTP and HTTPS) to port 80. The only evidence I will have to indicate whether the original request made was HTTP or HTTPS is via the X-Forwarded-For
header that is set by the load balancer. Is there a built-in, inexpensive way to handle redirection in Nginx when the original request was on HTTP? Keep in mind, I'll only have a server set up for port 80.
Nginx – Redirect from HTTP to HTTPS with respect to the X-Forwarded-For header (SSL termination used)
httphttpsload balancingnginxredirect
Related Topic
- Nginx – How to setup nginx to redirect to https for certain host when behind an SSL termination load balancer
- Nginx – How to redirect all HTTP traffic to HTTPS for a Django 1.4 application running on an EC2 with nginx/uWSGI behind ELB with an SSL cert
- Nginx – http in the Location-header when the original request was made over https
- Ssl – Is it bad to redirect http to https
- Nginx – Redirect all http requests behind Amazon ELB to https without using if
- Getting X-Forwarded behind AWS TCP Load Balancer for https
Best Answer
Assuming that you're guaranteeing that the X-Forwarded-For header is only set for SSL traffic ...
Although this is arguably something you should do at the balancer.