Skip to content

Instantly share code, notes, and snippets.

@i-amolo
Forked from mhulse/httpd.vhosts.conf
Created November 26, 2019 12:57
Show Gist options
  • Save i-amolo/012c1c71ef78f590a2d7799ebffafc07 to your computer and use it in GitHub Desktop.
Save i-amolo/012c1c71ef78f590a2d7799ebffafc07 to your computer and use it in GitHub Desktop.
Apache Tomcat 8.0: How to get “Virtual hosting” to work with port removed on OS X Yosemite?
# http://tomcat.apache.org/tomcat-7.0-doc/proxy-howto.html
# https://gerrydevstory.com/2013/06/29/tomcat-apache-reverse-proxy/
# http://www.latko.org/2009/02/12/installing-tomcat-60x-behind-apache-22x/
# http://stackoverflow.com/a/20584597/922323
# https://raajasoft.wordpress.com/2011/11/27/to-shorten-the-tomcat-application-url/
# http://www.christianroessler.net/tech/2012/apache-vhost-proxy-and-static-files.html
# http://sysadminnotebook.blogspot.com/2011/08/apache-reverse-proxy-of-virtual-hosts.html
# http://stackoverflow.com/a/8823415/922323
<VirtualHost *:80>
ServerName tomcat.local
ServerAlias www.tomcat.local
#DocumentRoot "/Users/mhulse/github/tomcat"
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyVia On
ProxyPreserveHost On
# APP:
ProxyPass /test http://127.0.0.1:8090/test
ProxyPassReverse /test http://127.0.0.1:8090/test
# MANAGER:
ProxyPass /manager http://127.0.0.1:8090/manager
ProxyPassReverse /manager http://127.0.0.1:8090/manager
#RewriteEngine On
#RewriteRule ^(.*)$ http://127.0.0.1:8090/test/$1 [P,L]
</VirtualHost>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8090" protocol="HTTP/1.1" proxyName="tomcat.local" proxyPort="80" redirectPort="8443" connectionTimeout="20000" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase" />
</Realm>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" startStopThreads="-1">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
<Host name="tomcat.local" appBase="webapps/test" unpackWars="false" autoDeploy="false">
<Logger className="org.apache.catalina.logger.FileLogger" directory="logs" prefix="virtual_log." suffix=".txt" timestamp="true" />
<Context path="" docBase="." debug="0" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="virtual_log." suffix=".txt" pattern="common" />
</Host>
</Engine>
</Service>
</Server>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment