I need your help.
I have 2 versions of the application running on the Linux machine. Version1 runs on localhost port 5000, version2 runs on localhost port 5001.
I need users to be able to access either of the application versions depending on the URL they use.
My existing Apache httpd.conf as follows:
When users type http:/my.company.com it redirects them to HTTPS port 443 and port 443 redirects to localhost 5000. This works.
<VirtualHost *:80>
ServerName my.company.com
Redirect / https://my.company.com/
</VirtualHost>
<VirtualHost *:443>
ServerName my.company.com/
TimeOut 600
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile /etc/pki/tls/certs/my.company.crt
SSLCertificateKeyFile /etc/pki/tls/private/my.company.key
</VirtualHost>
Now I need to make it when users type http://my.company.com:15000 it redirects them to some HTTPS port that redirects to localhost 5001 where my application is listening.
If there is another way to do this, like use a different domain name like my-v2.company.com it would also work. I can create a new DNS entry. The idea is that when users use a different port or a different domain it should redirect them to a different application port.
I tried searching here and tried multiple setups and cannot make it work this way.
You can define multiple
VirtualHost
s for the same port, you just have to set different ServerName directives for each.If you want my.company.com to be the application at port 5000, and my-v2.company.com to be the application at port 5001, I'd suggest that you go with a configuration like this:
The real magic about this answer is the first two lines, which tell Apache to allow creating two VirtualHosts on the same port and to differentiate them by the ServerName that has been set.