ERROR: TOO MANY REDIRECTS after setting up load balancer with EC2 t2 micro instance

Keywords: WordPress - AWS - Technical issue - Other
My website is on EC2 - t2 micro instance

After configuring a Load balancer for my website on EC2, website is not loading and getting the error: TOO MANY REDIRECTS
I followed this documentation;

I did setup the load balancer successfully and modified the Server configuration as advised. (Followed all steps in the documentation)

I found the same issue mentioned in forums several times. The solution they had given was, including this code on wp-config.php file:

if (strpos($_SERVER[‘HTTP_X_FORWARDED_PROTO’], ‘https’) !== false)

But I have already added this code and rechecked it several times.

Checked for the system status as well and all services are up and running.
Rebooted the server 2 times

Hope you could support me and provide a solution.

Hello @erandaind93,

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

Francisco de Paz

Initiated the support tool and following message came up finally:

The support bundle file was successfully created, but the automatic upload to Bitnami servers failed. You will need to upload it to your Bitnami Support ticket manually. Please locate the following file in your file browser or in your terminal: /tmp/ Exercise caution when uploading the resulting support bundle to public sites as it contains detailed diagnostic information

I couldn’t find the file created from the file directory. Is there a exact location? I could find a temp folder but it’s empty. can you tell me how to locate the file created?

Hi @erandaind93,

The file should be at /tmp/, can you run the following command and check whether it outputs the filename:

ls /tmp/

If the file doesn’t exist, please try running the support too again.

Francisco de Paz

Hi @fdepaz
Sent a message with gdrive link just now.

Any update on this?

Hello @erandaind93,

Please try changing your Apache’s configuration at opt/bitnami/apache2/conf/bitnami/bitnami.conf to the following:

  # BEGIN: Support domain renewal when using mod_proxy without Location
  <IfModule mod_proxy.c>
    ProxyPass /.well-known !
  # END: Support domain renewal when using mod_proxy without Location
  # BEGIN: Enable HTTP to HTTPS redirection
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteCond %{REQUEST_URI} !^/\.well-known
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  # END: Enable HTTP to HTTPS redirection
  # BEGIN: Enable non-www to www redirection
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTP_HOST} !^localhost
  RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
  RewriteCond %{REQUEST_URI} !^/\.well-known
  RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
  # END: Enable non-www to www redirection

Replacing your three rewrite rules for these two should solve the loop of redirections. The problem should be at the second RewriteRule that was redirecting to Although the condition %{HTTP:X-Forwarded-Proto} !https should be unnecessary as you already have %{HTTPS} !=on there is no harm leaving it there. After that, restart Apache running:

sudo /opt/bitnami/ restart apache

Francisco de Paz

Thanks for the reply.

I made the changes as per the last reply.
But the error still remains

Can you provide another solution pls

Hello @erandaind93,

There are several Apache’s errors related to PageSpeed and several plugins. Could you please disable PageSpeed following our Use PageSpeed With Apache guide and your plugins from the console as explained in Debug WordPress Errors.

After that, restart your instance and check whether the issue is solved. In the case the problem persists, please provide a new bnsupport report. If possible, please paste the code here.

Francisco de Paz