Making app connections with mod_proxy

Apache’s mod_proxy has many uses. By far the most common is to provide an extra layer of security for application servers by acting as the gatekeeper for client connections. Another would be enhancing performance in conjunction with mod_cache.

In the simple example below I’ve set up a named virtual host to proxy connections coming in on port 80 to a different port on another server. This could be a web server or an application server, depending on the need. In this example I’m also doing a reverse proxy, which means that all communications between the client and end point server go through the same Apache instance.

<VirtualHost *:80>
DocumentRoot /var/www/html/www2
ServerName www2.example.com
ServerAdmin me@example.com
ErrorLog /var/log/httpd/www2_error_log
CustomLog /var/log/httpd/www2_access_log common
ProxyRequests Off
ProxyPass /newapp http://server2.example.com:15001/newapp
ProxyPassReverse /newapp http://server2.example.com:15001/newapp
</VirtualHost>