I have two web applications that run on the same server. Each require a different port number, but only one port is open to the public. My company would rather avoid opening another port up but still wants both to be apps public, so I'm trying to figure out how to have both run. I know a little about apache, but I'm confused on how to set it up to do this. Should I use a reverse proxy or is there another way to accomplish my goal?
1 Answer
You can use apache virtual hosts. Look at this page. You can use another subdomain for the other app. No need to purchase a new domain. Also, you don't need to change the port number. For example, you can use:
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/app1
ServerName app1.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/app2
ServerName app2.example.com
# Other directives here
</VirtualHost>
In this example, the app1 will reside in /var/www/app1
and app2 will reside in /var/www/app2
http://example.com:81/
?