How to handle multiple apps via port 443

apache-2.2httpd.confport-443redirect

I am not an expert by any means in regard to apache (in our case Oracle's version of apache, OHS) and redirecting input within httpd.conf. We have multiple applications deployed on WLS 10.3.5 on the same server and would like to have them all accessed via port 443.

Of course, not all the apps can be deployed on 443 we would then receive an error that the port is in use.

For example, we have app1 deployed on 3443, app2 deployed on 4443, and app3 on 5443. Our client, would like to be able to simply enter https:///app1 (or app2 or app3) and not https://:3443/app1 (or :4443/app2 or :5443/app3).

Is it possible to do this within the httpd.conf (or ssl.conf)? Is it possible to have the URLs only use 443 and then within the conf files redirect to where the apps are actually deployed (3443, 4443, and 5443)?

Best Answer

This can certainly be achieved, and the way you would do it depends upon how your apps run; if they are served by your web server simply listening on certain ports, then you would need to amend your configurations to use VirtualHosts similar to the following:

<VirtualHost *:443>
    ServerAlias app1.com
    DocumentRoot /var/www/html/app1    #or however this app is configured   
    [the rest of your configuration directives for the app]
</VirtualHost>

<VirtualHost *:443>
    ServerAlias app2.com
    [As above but for app2]
</VirtualHost>

Whereas, if your apps are being served by other processes listening on the ports you have noted, then you could set it up using a structure similar to the above, but utilising reverse proxies to serve the apps via port 443, for example:

<VirtualHost *:443>
    ServerAlias app1.com
    ProxyPreserveHost on

    SSLProxyEngine On
    ProxyPass / http://localhost:5443/ #change the port here for the app in question
    ProxyPassReverse / http://localhost:5443/ # change the port here for the app in question

  SSLEngine on
  [SSL directives as appropriate for your requirements]
</VirtualHost>

<VirtualHost *:443>
    ServerAlias app2.com
    ProxyPreserveHost on


    SSLProxyEngine On
    ProxyPass / http://localhost:5443/ #change the port here for the app in question
    ProxyPassReverse / http://localhost:5443/ # change the port here for the app in question

  SSLEngine on
  [SSL directives as appropriate for your requirements]
</VirtualHost>

This way, the SSL is handled by the web server, with the http requests passed back to whichever app is listening on the ports listed - and the apps are differentiated via host name requested. It is worth noting that if the apps are listening on these ports and replying only over SSL, it will be advisable to disable SSL from them (and run it via Apache as instructed above - once configured, also of course close those ports in your firewall if they are currently opened externally).