Apache virtualhost mod_proxy example
for example
same ip
apache 80 port -> tomcat 8080 port (use reverse proxy)
apache 19080 port -> tomcat 9080 port(use virtual host)
apache conf modifications
Listen 80
Listen 19080
>ServerName my.intranet.net
ProxyPreserveHost On
ProxyPass /S010 http://192.168.144.179:9080/
ProxyPassReverse /S010 http://192.168.144.179:9080/
remember to include the modules for mod_proxy
We are going reverse-proxy i.e. send the request to other application servers. apache2 is going to be the reverse proxy server, tomcat and jenkins the other application servers.
To do this you need to enable the mod_proxy module in apache2.
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_ajp
$ ls /etc/apache2/mods-enabled/
access_compat.load autoindex.load mpm_prefork.conf rewrite.load
alias.conf cgi.load mpm_prefork.load setenvif.conf
alias.load deflate.conf negotiation.conf setenvif.load
auth_basic.load deflate.load negotiation.load socache_shmcb.load
authn_core.load dir.conf php5.conf ssl.conf
authn_file.load dir.load php5.load ssl.load
authz_core.load drupal.conf proxy_ajp.load status.conf
authz_groupfile.load env.load proxy.conf status.load
authz_host.load filter.load proxy.load
authz_user.load mime.conf reqtimeout.conf
autoindex.conf mime.load reqtimeout.load
<VirtualHost *:*>
...
ProxyPass /tomcat http://tomcat:8080/
ProxyPassReverse /tomcat http://tomcat:8080/
<LocationMatch /tomcat/>
Order allow,deny
Allow from all
</LocationMatch>
...
</VirtualHost>
Comments