[英]Why my AWS Lightsail instance got “Health Check: Failed” when attach to a load balancer?
我也在AWS Lightsail
創建了一個AWS Lightsail instance
和一個Load Balancer
。 當我將我的實例附加到負載均衡器時,我得到以下狀態: Health Check: Failed
。 我不知道為什么? 我去我的 WordPress,一切正常。
更新:據我所知,LB 僅在端口 80 上檢查我的實例運行狀況,這是 HTTP 協議。 我已經檢查過了,它總是返回HTTP/1.1 301 Moved Permanently
。 我已經在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]
這些在wp-config.php 中:
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
這些在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]
並重新啟動我的 apache 但它仍然無法正常工作。
所以我找到了一個解決方案: https : //community.bitnami.com/t/lightsail-load-balancer-failed/81546/13
之后,我需要創建一個文件health.txt
自定義我的健康檢查路徑到這個文件: http://{MY_IP_INSTANCE}/health.txt
。
並將這些添加到我的bitnami.conf :
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
然后重新啟動我的 apache 服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.