Reputation: 9
I created an AWS Lightsail instance
and a Load Balancer
also in AWS Lightsail
.
When I attached my instance to the load balancer, I got this status: Health Check: Failed
. I don't know why? I go to my WordPress and everything works fine.
Updated:
As I know, the LB only check my instance health on port 80, which is HTTP protocol. I have checked it and it always return HTTP/1.1 301 Moved Permanently
. I have already add these in httpd-prefix.conf:
SetEnvIf x-forwarded-proto https HTTPS=on
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
And these in wp-config.php:
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
And these in bitnami.conf:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
And restart my apache but it still not works.
Upvotes: 0
Views: 3404
Reputation: 557
I had the same issue with AWS lightsail instances using lightsail CDN. This is how I fixed the health failure problem:
Click your lightsail instance
Connect using SSH
Navigate to /opt/bitnami/apps/wordpress/htdocs
Create an empty HTML file by running the following command:
touch health.html
Reboot your instance
Upvotes: 0
Reputation: 9
So I found a work around solution on topic: https://community.bitnami.com/t/lightsail-load-balancer-failed/81546/13
Following that, I need to create a file health.txt
customize my health check path to this file: http://{MY_IP_INSTANCE}/health.txt
.
And add these to my bitnami.conf:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Then restart my apache server.
Upvotes: 1