附加到负载均衡器后,为什么我的AWS Lightsail实例会收到“运行状况检查:失败”的信息?

问题描述

我还在AWS Lightsail instance中创建了Load BalancerAWS Lightsail。 将实例连接到负载均衡器后,状态为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

接着,我需要创建一个文件 string path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; if (File.Exists(path)) { XDocument XDoc = XDocument.Load(path); foreach (var node in XDoc.Nodes()) { if (!string.IsNullOrEmpty(node.ToString())) { string S = node.ToString(); string Word = ""; for (int i = 0; i < S.Length; i++) { if (IsAcceptedChar(S[i])) Word += S[i]; else { if (Word == "setting name") { ,以自定义我对该文件的健康检查路径:health.txt

并将它们添加到我的 bitnami.conf

http://{MY_IP_INSTANCE}/health.txt

然后重新启动我的Apache服务器。