Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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
使用ALB的Wordpress站点中出现HTTPS坏网关错误_Wordpress_Amazon Web Services_Ssl_Amazon Elb - Fatal编程技术网

使用ALB的Wordpress站点中出现HTTPS坏网关错误

使用ALB的Wordpress站点中出现HTTPS坏网关错误,wordpress,amazon-web-services,ssl,amazon-elb,Wordpress,Amazon Web Services,Ssl,Amazon Elb,我有一个用ALB实现的wordpress站点。我有ACM,并为端口443和80设置了目标组。我为healthcheck制作了一个脚本,如下链接: 它可以与http(80)配合使用,但使用HTTPS(443)时会出现502错误网关。443的ALB healthcheck状态不正常。我在谷歌上搜索并尝试了不同的解决方案,但它仍然没有被修复 我在wp-config.php中修改了以下几行: if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https')

我有一个用ALB实现的wordpress站点。我有ACM,并为端口443和80设置了目标组。我为healthcheck制作了一个脚本,如下链接:

它可以与http(80)配合使用,但使用HTTPS(443)时会出现502错误网关。443的ALB healthcheck状态不正常。我在谷歌上搜索并尝试了不同的解决方案,但它仍然没有被修复

我在wp-config.php中修改了以下几行:

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
   $_SERVER['HTTPS']='on';
....
....
define( 'WP_SITEURL', 'https://mywordpress.no' );
define( 'WP_HOME', 'https://mywordpress.no' ); 
在/etc/httpd/conf/httpd.conf中添加了以下行

Listen 80
<VirtualHost *:80>
  DocumentRoot /var/www/html/
  ServerName mywordpress.no
</VirtualHost>

<VirtualHost *:443>
  ServerName mywordpress.no
  DocumentRoot /var/www/html

 # This line is super important and will ensure that wordpress renders https links

  SetEnvIfNoCase X-FORWARDED-PROTO "^https$" HTTPS

  <Directory /var/www/wordpress>
    Options FollowSymLinks
    AllowOverride FileInfo Options
    Require all granted
  </Directory>

  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>

  LogLevel info
  ErrorLog /var/log/wordpress-error.log
  CustomLog /var/log/wordpress-access.log combined

  RewriteEngine On
</VirtualHost>

任何帮助都将不胜感激。

443的ALB healthcheck状态不正常,这表明您将ALB配置为期望实例与端口443上的平衡器使用HTTPS,这是不正确的。您应该能够在端口80上以HTTP的形式将所有流量发送到实例。显示或描述ALB中的目标群?@Michael sqlbot非常感谢:)它解决了问题。很高兴听到这个消息。我们应该为未来的游客制定一个恰当的答案。你到底换了什么?您是否将两个目标组合并为一个,以便所有内容都达到80(443是否设置为HTTPS?),或者您是否将443目标组从HTTPS重新配置为HTTP,或者是其他内容?添加注释,我将添加一个更详细解释解决方案的答案。@Michael sqlbot您好,我有两个目标组,一个用于端口80,另一个用于端口443。我已删除端口为443的targetgroup。现在我只有一个tg(80),我将侦听器(80443)转发到该tg。但我现在面临另一个问题,在我将其更改为HTTPS后,管理页面没有显示。您对此有什么想法吗?管理员页面问题通过设置安全组(允许从ALB到EC2的所有流量)得到解决。我还对.htaccess文件中的部分(#对于在端口80(http)上运行的站点)进行了注释。
 # BEGIN WordPress
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /

 # For a site running on port 443 or else (http over ssl)
 RewriteCond %{SERVER_PORT}  !^80$
 RewriteRule !^wp-(admin|login|register)(.*) - [C]
 RewriteRule ^(.*)$ http://%{SERVER_NAME}/$1 [L]

 # For a site running on port 80 (http)
 RewriteCond %{SERVER_PORT}  ^80$
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^wp-(admin|login|register)(.*) https://%  {SERVER_NAME}:10001/wp-$1$2 [L]

 RewriteCond %{SERVER_PORT}  ^80$
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>

 # END WordPress
Listeners:
 HTTP : 80    forward to tg-http
 HTTPS : 443  forward to tg-http

Target-Groups:
 Port:     Protocol:
 80        HTTP

TargetGroup- HealthCheck:
 Protocol   HTTP
 Path   /wp-content/themes/example-theme/health-check.php
 Port   traffic port