Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have configured an AWS ELB to point to my Ubuntu Server running the Wordpress 3.2.1. Everything worked great on the server until I put it behind a load balancer.

I setup the load balancer to forward port 80 to port 80 and port 443 to port 80.

I setup my virtual hosts file to check for the headers from the elb:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Now whenever I go to an https url I get this message:

This webpage has a redirect loop
The webpage at has resulted in too many redirects

As soon as I disable the wordpress https plugin
The pages work but are now full of mixed content. pages that should be https are no longer https.

As soon as I access the server directly instead of through the elb it works again.

Any ideas on how I could get this to work with an AWS ELB?

share|improve this question
have you update the permalink? usually we have to update the permalink setting on wordpress – user905953 Aug 24 '11 at 20:45
up vote 8 down vote accepted

I would hazard a guess without you posting your ELB configuration that the ELB is redirecting HTTPS (443/tcp) traffic to the EC2 instance on HTTP (80/tcp). Then you're .htaccess and plugin are trying to redirect it back to HTTPS because it is being seen over HTTP.

Go take a look at your EC2 console under Network & Security > Load Balancers and I would imagine you'll see the Port Configuration says something along the lines of 443 forwarding to 80 (HTTPS, Certificate: blah)

share|improve this answer
This person here was having the same problem.… – ChickenFur Aug 24 '11 at 22:40
and this one looks similar… – ChickenFur Aug 24 '11 at 22:43
your right I am forwarding 443 to 80. – ChickenFur Aug 24 '11 at 22:43
I've been running one of my clients under AWS for over 2 years now... When I read your question that's the first thing that popped into my head as suspect. – Jeremy Bouse Aug 25 '11 at 0:56
Changing the LB to point from 443 to 443 fixed it :) Thanks! – ChickenFur Aug 25 '11 at 19:53

Try adding this to your httpd.conf or an .htaccess


When using the load balancer + HTTPS, your webserver is unaware that HTTPS is being used on the front end, so keeps trying to redirect to the HTTPS site, when in fact, HTTPS is already being used.

The above will translate the header that Amazon's Load Balancer sends (X-Forwarded-Proto: https) into an environment variable that Wordpress and other PHP scripts understand (HTTPS=1)

share|improve this answer
This would be correct way do it, as SSL decryption remains on ELB – toske Jun 30 '15 at 10:47

According to Amazon here the fix is:

/** Detect if SSL is used. This is required since we are terminating SSL either on CloudFront or on ELB */ 

I still ended up with the endless loop, so I changed my WordPress config as from:




This will force users to https, even if they type http, plus it makes it easy to develop the site offline because you just update the WP_HOME to local host and https is no longer the default

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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