Tweetegy On the edge of chaos with Blockchain, Dapps, DeFi, JavaScript

| About | Search | Archive | Github | RSS |

How to return content from an application running on a specific port in apache

Continuing on from the previous post where I explain how to show content from a different root folder depending on the sub domain e.g. will actually return content from (without changing the URL). Today I will extend this idea to show content from a separate service running on a different port within the same server. So in this case a call to returns

As in the previous post, we assume that you already have your sub domain DNS settings correctly configured and the subdomain now points to the IP address of your server, you should do the following in Apache running on an Ubuntu server.

Open the configuration file for your site. In this example, we will use the default site.

nano /etc/apache2/sites-available/default

Add the following additional VirtualHost configuration to the end of the file (change the port number on localhost if you need to, of course!)

<VirtualHost *:80>
  ProxyPass / http:// localhost:3000/
  ProxyPassReverse / http:// localhost:3000/
  ProxyPreserveHost on
  <Proxy *>
   allow from all

Now restart apache and your all done!

/etc/init.d/apache2 restart