skip to Main Content

I have a URL, http://example.com, that I would like to use to serve content from my GitHub Pages site at https://myusername.github.io/mysite/ via a reverse proxy in Apache. This is both as a temporary workaround until I update example.com‘s DNS setting to point to GitHub Pages, as well as to teach myself how reverse proxies work.

I have my Apache config like so:

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

When I try to go to “example.com”, I get “The proxy server could not handle the request GET /.
Reason: Error during SSL Handshake with remote server.”

Is what I’m trying to do possible, and if so, what should I be changing?

I’m using Apache 2.2.

3

Answers


  1. You should probably remove the line:

    SSLEngine On

    It enables HTTPS on your port 80… but you don’t provide an SSL certificate (…and HTTPS uses port 443).
    You should also add the line:

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

    Login or Signup to reply.
  2. The following config works perfectly on reverse proxy github pages

    <VirtualHost *:80>
            ServerName custom-domain
            ServerAdmin [email protected]
    
            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>
    

    Make sure you replace myusername with your github username, mysite with your github repo name and custom-domain with your custom url

    Login or Signup to reply.
  3. You don’t have to implement a reverse proxy yourself, since Github allows you to specify a custom domain

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search