Skip to content →

How to configure an AJP proxy and Apache Webserver.

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.
e.g.

 http://www.johndoe.com:8080/joomla/admin

As a general rule of thumb, I write things down after techies ask me more than 5 times the same question.

Apache Web Server to the rescue

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

 http://www.johndoe.com/joomla/admin

directly to

 http://www.johndoe.com:80/joomla/admin

for the PHP engine and all incoming requests to the Wildfly service

 http://www.johndoe.com/wildfly/

to

 http://www.johndoe.com:28080/wildfly/

and similar for the TomEE service/server.

There are few prerequesites for the routing to work.

  1. Enable and configure the proxy module. See here.
  2. Enable AJP on your service. AJP stands for Apache JServe Protokol and is binary. Lighting fast, but binary. Make sure your service operates AJP.
  3. 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.
1
2
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

 

tag.

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.

<VirtualHost *:443>

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>

Published in Proxies and Routing Server Configuration

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *