Check our Summer Specials! Get a Free Account or SEO Bundle with 80% off. View Offers

Configure Apache proxy for Ghost on cPanel

Making Ghost blog accessible on port 80 with Apache proxy

If you install Ghost via Softaculous on a cPanel server most probably your Ghost URL will look like http://blog.example.com:62227. The numbers after your domain name represent the Node port which service all requests to your Ghost blog. As Node is a standalone service it requires a dedicated port different than the standard port 80 used by the Web Server.

 

Still, this might be very inconvenient for your visitors and you might want to have your Ghost blog accessible via the standard port 80. To achieve this you will need to perform a few easy steps on your server to configure the Apache proxy to redirect all requests to your custom Ghost blog installation port.

 

We can help

In case you are hosting your Ghost blog on FastComet Ghost Hosting Package, please contact our support team and we will set this for you in just a few minutes. If you are managing your server on your own, please follow the steps below.

Step 1 Create userdata directory

First, you will need to create a folder under the 'userdata' directory of your Apache web server. This can be done by executing:

 

mkdir -p /usr/local/apache/conf/userdata/std/2/USERNAME/DOMAIN/

 

Please replace 'USERNAME' with your actual cPanel username and 'DOMAIN' with your actual domain or subdomain under which Ghost is installed. 

 

Step 2Create proxy config file

When the needed folders are created enter into your domain userdata directory and create a text file called ghost.conf. The content of the ghost.conf file should be:

 

ProxyPass / http://127.0.0.1: 62227/
ProxyPassReverse / http://127.0.0.1: 62227/

 

Please replace the port number 62227 with your actual Ghost port number provided to you during the installation process. When you are ready save the file and exit the text editor program. 

 

Step 3Include the proxy config file into httpd.conf

Next, you will need to edit your Apache httpd.conf. The exact path to the file is:

 

/etc/httpd/conf/httpd.conf

 

You can open the httpd.conf via your favorite text editor and you should search for your domain or subdomain vhost which should look like:

 

<VirtualHost 192.168.1.30:80>
    ServerName blog.example.com
    ServerAlias www.blog.example.com
.........
    # To customize this VirtualHost use an include file at the following location
    # Include "/usr/local/apache/conf/userdata/std/2/example/blog.example.com/*.conf"
</VirtualHost>

 

Here you should uncomment the last line which include all .conf files from the directory you have just created. This can be done by removing the '#' sign at the beginning of the line. When you are ready save the file and exit the text editor program.

 

Now you should restart your Apache web service by executing:

 

/etc/init.d/httpd restart

 

After the Apache restart all requests should be automatically handled by the Apache and redirected internally to the Node custom port. Now you can conveniently access your Ghost blog directly via your URL without the need to include the port number.

 

If you experienced any difficulties during the process, please contact our support team and we will configure your Ghost blog for you.