Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 为什么我的AWS Lightsail实例;运行状况检查:失败";何时连接到负载平衡器?_Wordpress_Amazon Web Services_Amazon Lightsail_Aws Load Balancer - Fatal编程技术网

Wordpress 为什么我的AWS Lightsail实例;运行状况检查:失败";何时连接到负载平衡器?

Wordpress 为什么我的AWS Lightsail实例;运行状况检查:失败";何时连接到负载平衡器?,wordpress,amazon-web-services,amazon-lightsail,aws-load-balancer,Wordpress,Amazon Web Services,Amazon Lightsail,Aws Load Balancer,我在AWS Lightsail中创建了一个AWS Lightsail实例和一个负载平衡器。 当我将实例连接到负载平衡器时,我得到以下状态:运行状况检查:失败。我不知道为什么?我去我的WordPress,一切正常 更新: 正如我所知,LB只在端口80上检查我的实例运行状况,这是HTTP协议。我检查了它,它总是返回HTTP/1.1 301永久移动的。我已经在httpd prefix.conf中添加了这些: SetEnvIf x-forwarded-proto https HTTPS=on Rewr

我在
AWS Lightsail
中创建了一个
AWS Lightsail实例和一个
负载平衡器。
当我将实例连接到负载平衡器时,我得到以下状态:
运行状况检查:失败
。我不知道为什么?我去我的WordPress,一切正常

更新: 正如我所知,LB只在端口80上检查我的实例运行状况,这是HTTP协议。我检查了它,它总是返回HTTP/1.1 301永久移动的
。我已经在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]
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
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]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
wp config.php中:

SetEnvIf x-forwarded-proto https HTTPS=on

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
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]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
而这些在bitnami.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]
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
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]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

然后重新启动我的apache,但它仍然无法工作。

因此我找到了一个关于主题的解决方案:

接下来,我需要创建一个文件
health.txt
自定义此文件的健康检查路径:
http://{my_IP_INSTANCE}/health.txt

并将这些添加到我的bitnami.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]
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';
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]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{REQUEST_URI} !health.txt
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

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

您是如何定义健康检查的?请检查HCs中的预期状态代码。默认值为200,但wordpress可能会返回302或303进行自动重定向。@petern在文档中,他们说,
Lightsail在web应用程序的根目录(“/”)上对实例执行运行状况检查。我的网站正在运行@Marcin我如何检查您的HCs中的预期状态代码。先生