How to Proxy Multiple Ghost Blogs using Apache
If you already have apache installed, by default, on CentOS, the main Apache configuration file can be found in /etc/httpd/conf.d
. On Ubuntu it can be found in /etc/apache/
.
If you don't have apache installed, you can use the following command:
sudo apt-get install apache2
Make sure mod-proxy is enabled:
a2enmod proxy
a2enmod proxy_http
Create a new conf file, or edit your existing conf file in the sites-available
folder (conf file could also be httpd.conf
in root folder). This is similar to what the conf file will look like if your proxying to one Ghost blog:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName your-url.com
ServerAlias www.your-url.com
ProxyRequests off
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http://127.0.0.1:2368/
</VirtualHost>
To add a second proxy, we need to create a second virtual host. Copy the virtual host section, paste it below the existing one and then update the URLs and the port at the end of the ProxyPass
commands:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName your-url.com
ServerAlias www.your-url.com
ProxyRequests off
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http:/127.0.0.1:2368/
</VirtualHost>
<VirtualHost *:80>
ServerName your-second-url.com
ServerAlias www.your-second-url.com
ProxyRequests off
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
Note: 2368 is Ghost's default port, so if you are running a second instance of Ghost, you need to edit it's config to run on a different port
Now restart Apache:
CentOS:
sudo service httpd restart
Ubuntu
sudo service apache2 restart
Now you should be able to go to the url specified in either config and it will point you to the correct Ghost instance!