【问题标题】:Reverse proxy an http:// domain to a GitHub Pages URL将 http:// 域反向代理到 GitHub Pages URL
【发布时间】:2020-04-02 19:25:06
【问题描述】:

我有一个 URL http://example.com,我想通过 Apache 中的反向代理来提供来自我的 GitHub Pages 站点 https://myusername.github.io/mysite/ 的内容。在我更新 example.com 的 DNS 设置以指向 GitHub Pages 之前,这既是一种临时解决方法,也是为了自学反向代理的工作原理。

我的 Apache 配置如下:

<VirtualHost *:80>
    ServerName example.com
    SSLEngine On
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    ProxyPass "/" "https://myusername.github.io/mysite/" 
</VirtualHost>

当我尝试访问“example.com”时,我收到“代理服务器无法处理请求 GET /. 原因:与远程服务器进行 SSL 握手时出错。”

我正在尝试做的事情是否可行,如果可以,我应该改变什么?

我使用的是 Apache 2.2。

【问题讨论】:

    标签: apache ssl reverse-proxy


    【解决方案1】:

    您可能应该删除该行:

    SSLEngine On

    它在您的端口 80 上启用 HTTPS...但您没有提供 SSL 证书(...并且 HTTPS 使用端口 443)。
    您还应该添加以下行:

    ProxyPassReverse "/" "https://myusername.github.io/mysite/"

    【讨论】:

      【解决方案2】:

      以下配置在反向代理 github 页面上完美运行

      <VirtualHost *:80>
              ServerName custom-domain
              ServerAdmin encycode@gmail.com
      
              ProxyRequests Off
              ProxyPreserveHost On
              SSLProxyEngine on
              SSLProxyVerify none
              SSLProxyCheckPeerCN off
              SSLProxyCheckPeerName off
              SSLProxyCheckPeerExpire off
      
              RequestHeader set Host "myusername.github.io"
              RequestHeader set X-Forwarded-Proto https
              RequestHeader set Origin "myusername.github.io"
      
              ProxyPass / https://myusername.github.io/mysite/
              ProxyPassReverse / https://myusername.github.io/mysite/
      </VirtualHost>
      

      确保将 myusername 替换为您的 github 用户名,将 mysite 替换为您的 github 存储库名称,将 custom-domain 替换为您的自定义 url

      【讨论】:

        【解决方案3】:

        您不必自己实现反向代理,因为 Github 允许您指定自定义域

        https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github- pages-site

        【讨论】:

          猜你喜欢
          • 2021-01-16
          • 2022-11-28
          • 1970-01-01
          • 2017-07-10
          • 1970-01-01
          • 2016-10-16
          • 2016-09-30
          • 1970-01-01
          • 2015-05-05
          相关资源
          最近更新 更多