AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 978853
Accepted
klor
klor
Asked: 2019-08-12 21:48:08 +0800 CST2019-08-12 21:48:08 +0800 CST 2019-08-12 21:48:08 +0800 CST

Moodle 3.7 & Apache & 反向代理结果 ERR_TOO_MANY_REDIRECTS

  • 772

具有反向代理结果 ERR_TOO_MANY_REDIRECTS 的 Moodle 3.7 Apache。

我在前端服务器上有一个带有以下 vhosts 文件的 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;

知道为什么当我尝试打开https://moodle.site.com URL 时在 Google Chrome 中出现“ERR_TOO_MANY_REDIRECTS”错误吗?

编辑1:

101.102.103.104 是 Moodle 后端服务器的 IP 地址。前端服务器有moodle.site.com 子域名,解析为1.2.3.4。用户输入moodle.site.com URL,它应该从101.102.103.104 IP 地址反向代理来自Moodle 后端服务器的内容。

apache-2.4
  • 3 3 个回答
  • 3933 Views

3 个回答

  • Voted
  1. lisandro
    2020-12-03T05:41:15+08:002020-12-03T05:41:15+08:00

    我无权访问 Web 服务器配置,所以我必须找到这个解决方法。文件 lib/setuplib.php,在我的例子中,第 900 行,Moodle 对此的注释:$CFG->sslproxy 指定是否使用外部 SSL 设备(即,Moodle 服务器使用 http,外部框将所有内容转换为 https)。

    改变

      if (empty($CFG->sslproxy))
    

    为了

      if (!empty($CFG->sslproxy))
    

    这就是开始正常安装所需要的一切。(经过两个小时的调试,到处都插入 die())

    • 1
  2. Javier Sarsa
    2020-12-30T05:13:59+08:002020-12-30T05:13:59+08:00

    我有同样的问题。不要更改 setuplib.php 中的任何内容。只需删除$CFG->reverseproxy = true;php.config 中的 并在 config.php 中包含到您的moodle安装的路径为 https:// $CFG->wwwroot....。

    因此,您的 config.php 文件将包含:

    $CFG->wwwroot = "https://server/dirs";
    $CFG->sslproxy = true;
    
    • 1
  3. Best Answer
    klor
    2020-01-21T10:27:37+08:002020-01-21T10:27:37+08:00

    我有 4 个问题,所以我必须修复它们(命令行命令应该以 root 身份执行或使用 sudo):

    1) 在代理服务器上,未激活 mod_ssl Apache 模块。在命令行中测试,如果 mod_ssl 处于活动状态:

    apache2ctl -M | grep ssl
    

    应该显示这个(如果激活):

    ssl_module (shared)
    

    FIX(在命令行中启用 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)
    

    FIX(在命令行中启用 mod_headers):

    a2enmod headers
    

    3) 我不得不在 Apache vhost conf 文件中使用 https ProxyPass URL 而不是 http:

    错误的:

    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) 必须打开 SSLProxyEngine 指令才能在 Apache vhost conf 文件中的 ProxyPass 中使用 SSL。

    修复: 在 /etc/apache2/sites-available/myvhost.conf 中添加 SSLProxyEngine

    SSLProxyEngine on
    
    • 0

相关问题

  • Apache2 - SSL 不工作

  • Apache <VirtualHost> 标签,如果客户端的 IP = x 则不重定向... 怎么做?

  • 我无法启用我的网站?[关闭]

  • SELinux 阻止 Apache 写入文件

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve