Running multiple services on a single host and domain forced me to think early about routing incoming traffic correctly – trying to avoid user impositions like rememberig port numbers for certain services.
As a general rule of thumb, I write things down after techies ask me more than 5 times the same question.
Also as a general rule, each service on this dedicated host has it’s own port. To avoid adjecent port numbers Apache Web Server ever since offered a sophisticated routing employing proxies. In my case I’m running a PHP engine, TomEE and a Wildfly for the same domain. I’m routing everything with the path
for the PHP engine and all incoming requests to the Wildfly service
and similar for the TomEE service/server.
There are few prerequesites for the routing to work.
- Enable and configure the proxy module. See here.
- Enable AJP on your service. AJP stands for Apache JServe Protokol and is binary. Lighting fast, but binary. Make sure your service operates AJP.
- Last but certainly not least, set the proxy configuration for your virtual host. You do that in your httpd.conf file – or if for example you are running Plesk – in additional vhost.conf file within the same directory.
ProxyPass /ccms ajp://127.0.0.1:28009/ccms ProxyPassReverse /ccms ajp://127.0.0.1:28009/ccms
The Plesk configuration would overwrite any changes done to the httpd.conf file after restart. Thus, use this empty vhost.conf file to merge the default and your custom configuration. And yes, you may insert any additonal configurations like ErrorDocument 401 in there, too. It is processed as if you would copy it in between your
Send all traffic to https (SSL)
Yes, you want to do that also for the https SSL encrypted VirtualHost entry. I.E. add it to the vhost_ssl.conf file.
However, in case you have sensitive data you send of the website (like passwords), do yourself a favour and redirect all blunt http requests to https and have it encrypted. SSL encryption comes for free on PLESK with Let’s Encrypt. Also, PWA clients (Progressive Web Apps) do require a HTTPS connection.
In your vhost.conf file, just add the Redirect directive.
<VirtualHost *:80> ServerName johndoe.com Redirect / https://www.johndoe.com/ </VirtualHost>