Moodle 3.7&Apache&リバースプロキシ結果ERR_TOO_MANY_REDIRECTS

Moodle 3.7&Apache&リバースプロキシ結果ERR_TOO_MANY_REDIRECTS

リバースプロキシを使用するMoodle 3.7 Apacheでは、ERR_TOO_MANY_REDIRECTSが発生します。

次の仮想ホストファイルを含むSSLサイトがあります。

<VirtualHost *:80>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>     


<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName moodle.site.com:443

SSLEngine on
SecAuditEngine On
RewriteEngine On

    ProxyPreserveHost On
    ProxyPass / http://101.102.103.104:80/
    ProxyPassReverse / http://101.102.103.104:80/

</VirtualHost>                                  
</IfModule>

また、80個のポート要求をすべてSSLポートにリダイレクトします。

注文する

curl -I https://moodle.site.com/

結果:

HTTP/1.1 303 See Other
Date: Fri, 09 Aug 2019 19:13:33 GMT
Server: Apache/2.4.38 (Debian)
Strict-Transport-Security: max-age=15768000; includeSubDomains
Location: https://moodle.site.com
Content-Language: en
Content-Type: text/html; charset=UTF-8

Moodle config.phpには次のものがあります:

$CFG->wwwroot   = 'https://moodle.site.com';
$CFG->reverseproxy = true;
$CFG->sslproxy  = 1;

Google Chromeで開こうとしたときに「ERR_TOO_MANY_REDIRECTS」エラーが発生する理由はわかりますか?https://moodle.site.comURL?

ベストアンサー1

4つの問題があるため、修正する必要があります(コマンドラインコマンドはrootとして実行するか、sudoを使用して実行する必要があります)。

1) mod_ssl Apache モジュールが有効になっていません。コマンドラインでmod_sslが有効になっていることをテストします。

apache2ctl -M | grep ssl

以下が表示されます(アクティブな場合)。

ssl_module (shared)

固定する(コマンドラインでmod_sslを有効にします):

a2enmod ssl
# Considering dependency setenvif for ssl:
# Module setenvif already enabled
# Considering dependency mime for ssl:
# Module mime already enabled
# Considering dependency socache_shmcb for ssl:
# Enabling module socache_shmcb.
# Enabling module ssl.
# See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
# To activate the new configuration, you need to run:
# systemctl restart apache2

2)次のようにApache SSL confファイルでHeaderディレクティブを使用しています。

# Guarantee HTTPS for 180 days including sub domains 
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains"

この mod_headers Apache モジュールが必要なため、有効になりません。コマンドラインでmod_headersが有効になっていることをテストします。

apache2ctl -M | grep headers

以下が表示されます(アクティブな場合)。

headers_module (shared)

固定する(コマンドラインでmod_headersを有効にします):

a2enmod headers

3)Apache vhost confファイルでhttpの代わりにhttps ProxyPass URLを使用する必要がありました。

無効:

ProxyPass / http://101.102.103.104:80/
ProxyPassReverse / http://101.102.103.104:80/

いいね:

ProxyPass / https://101.102.103.104/
ProxyPassReverse / https://101.102.103.104/

4)Apache vhost confファイルのProxyPassでSSLを使用するには、SSLProxyEngineディレクティブをオンにする必要があります。

問題を解決してください: /etc/apache2/sites-available/myvhost.confにSSLProxyEngineを追加しました。

SSLProxyEngine on

おすすめ記事