Keywords: WordPress - AWS - Technical issue - Secure Connections (SSL/HTTPS)
Description:
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; https://docs.bitnami.com/aws/how-to/configure-elb-ssl-aws/#step-4-modify-the-web-server-configuration-on-the-bitnami-application-instance1
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['HTTPX_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
But I have already added this code and rechecked it several times.
What I have already done based on Bitnami documentation (regarding configuring the server) are as follows:
- updating the Apache server configuration on the Bitnami application instance to correctly handle SSL requests from the load balancer.
'SetEnvIf x-forwarded-proto https HTTPS=on'
manually editing the wp-config.php file
if (strpos($SERVER['HTTPX_FORWARDED_PROTO'], 'https') !== false) $_SERVER['HTTPS']='on';
Force HTTPS: Redirect all traffic to HTTPS by adding the following to /opt/bitnami/apache2/conf/bitnami/bitnami.conf
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
I restarted the apache again and these lines appear:
Unmonitored apache
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd stopped
Syntax OK
/opt/bitnami/apache2/scripts/ctl.sh : httpd started at port 80
Monitored apache
Looking forward to hearing from you @bitnamisupport