Reverse Proxy in Apache2: Having Trouble Figuring it Out

If you’re looking for some help, it’s important to provide as much context as possible so that people are able to assist you. Try to always mention:

  • What’s your URL?

It’s supposed to be https://hoanews.jongriffith.com

  • What version of Ghost are you using?
    latest official docker image

  • What configuration?
    docker???

  • What browser?
    chrome

  • What errors or information do you see in the console?
    Proxy error

  • What steps could someone else take to reproduce the issue you’re having?
    ???

I have Ghost running in a docker container on an Unraid server. The local address is http://192.168.1.140:2368 and it works.

I have Apache2 running on 192.168.1.200 and I have successfully deployed many other reverse proxies back to the “140” host. I’m having trouble with Ghost.

My first clue was that perhaps the config.production.json file in /var/lib/ghost needed to be edited. I did that, although I don’t know if I did it right.

The 2nd clue was that there’s something about x-forwarded-proto on the Reverse Proxy configuration information for Ghost. I’m not sure what this is nor how to implement it, or if I even need to.

My config.production.json is as follows:

{
  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

My apache configuration is as follows:

<VirtualHost 192.168.1.200:80 [fe80::41:f6ff:fe68:9051]:80>
    SuexecUserGroup "#1002" "#1002"

    ServerName hoanews.jongriffith.com

    DocumentRoot /home/hoanews/public_html

    ErrorLog /var/log/virtualmin/hoanews.jongriffith.com_error_log
    CustomLog /var/log/virtualmin/hoanews.jongriffith.com_access_log combined
    
    DirectoryIndex index.html index.htm index.php index.php4 index.php5

    <Directory /home/hoanews/public_html>
        Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
        allow from all
        AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
        Require all granted
        AddType application/x-httpd-php .php
    </Directory>

    ProxyPreserveHost On
    ProxyRequests off
    ProxyVia On

    ProxyPass / http://192.168.1.140:2368/
    ProxyPassReverse / http://192.168.1.140:2368/

    RewriteEngine on
    RemoveHandler .php
    RemoveHandler .php7.4
    RedirectMatch ^/(?!.well-known)(.*)$ https://hoanews.jongriffith.com/$1
    IPCCommTimeout 31
</VirtualHost>

<VirtualHost 192.168.1.200:443 [fe80::41:f6ff:fe68:9051]:443>
    SuexecUserGroup "#1002" "#1002"

    ServerName hoanews.jongriffith.com
    DocumentRoot /home/hoanews/public_html

    ErrorLog /var/log/virtualmin/hoanews.jongriffith.com_error_log
    CustomLog /var/log/virtualmin/hoanews.jongriffith.com_access_log combined

    DirectoryIndex index.html index.htm index.php index.php4 index.php5

    <Directory /home/hoanews/public_html>
        Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
        allow from all
        AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
        Require all granted
        AddType application/x-httpd-php .php
    </Directory>

    ProxyPreserveHost On
    ProxyRequests off
    ProxyVia On
    
    ProxyPass / http://192.168.1.140:2368/
    ProxyPassReverse / http://192.168.1.140:2368/

    RemoveHandler .php
    RemoveHandler .php7.4

    IPCCommTimeout 31
    SSLCertificateFile /etc/letsencrypt/live/hoanews.jongriffith.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/hoanews.jongriffith.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

I would love to know if there’s someone who can help me get this running correctly.

The goal is to be able to hit https://hoanews.jongriffith.com for the main ghost blog.

Apache is on 192.168.1.200
Ghost is on 192.168.1.140:2368

One other note: If I change the “url” in the config.production.json file to “https://hoanews.jongriffith.com” chrome will redirect to this address but I still get the same connection error.

Also, if I add a parameter to the Docker configuration in Unraid so that URL is https://hoanews.jongriffith.com then the config.production.json changes the url to http://localhost:2368 and Chrome attempts to redirect to the https://hoanews.jongriffith.com url with the same error, which is this:

Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request

Reason: Error reading from remote server

Apache/2.4.58 (Ubuntu) Server at hoanews.jongriffith.com Port 443

Any help would be awesome. I’m in over my head.

Log into your Apache server.

Using a tool like httpie, wget or curl, make an HTTP request to

http://192.168.1.140:2368

What response do you get? Does it respond at all? With what status code or error message?