title: Forward connection from Apache on 80 to Tomcat 6 on 8080 with mod_proxy
body: <p>I've a domain www.example.com, now I'm trying to forward the browser connection to <a href="http://myserveripaddress:8080/MyAppName" rel="nofollow">http://myserveripaddress:8080/MyAppName</a>, in order to let the user surf MyApp when they type www.example.com on their browser...</p>
  
  <p>To do this I wrote this tag within httpd.conf file of Apache (2.2.20):</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerName www.example.com
      ProxyRequest Off
  &lt;Proxy *&gt;
  Order deny,allow
  Allow from all
  &lt;/Proxy&gt;
  ProxyPass / http://myserveripaddress:8080/MyAppName/
  ProxyPassReverse / http://myserveripaddress:8080/MyAppName/    
  &lt;Location /&gt;
  Order allow,deny
  Allow from all
  &lt;/Location&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Then I've used the following tag into server.xml file of tomcat:</p>
  
  <p>
       ...
       
       ...
       
              </p>
  
  <p>The problem is that when I type www.example.com on browser I've this answer
  You don't have permission to access / on this server.
  Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2 Server at www.example.com Port 80</p>
  
  <p>If I try to connect to www.example.com/MyAppName, it works....</p>
  
  <p>So finally, how can i connect to MyApp just typing www.example.com into web browser??</p>
  
  <hr>
  
  <h2>Updated at 21.41 CET 1/1/11</h2>
  
  <p>This is my configuration:</p>
  
  <p>httpd.conf</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      DocumentRoot /var/www/MyAppName
      ServerName www.example.com
  &lt;/VirtualHost&gt;
  
  
  
  
  &lt;IfModule mod_jk.c&gt;
     JKWorkersFile /etc/apache2/workers.properties
     JkShmFile /var/log/apache2/mod_jk.shm
     JKLogFile /var/log/apache2/mod_jk.log
     JkLogLevel debug
     JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
     JkMount /MyAppName/* worker1
  &lt;/IfModule&gt; 
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>JkMount /* worker1
  </code></pre>
  
  <p>Within server.xml</p>
  
  <pre><code>&lt;Connector port="8009" protocol="AJP/1.3" /&gt;
  
  
  &lt;Host name="www.example.com"  appBase="/var/www/"
         unpackWARs="true" autoDeploy="true" deployOnStartup="true"
         xmlValidation="false" xmlNamespaceAware="false"&gt;
         &lt;Context path="" docBase="/var/www/MyAppName"/&gt;
  </code></pre>
  
  <p>Within worker.properties</p>
  
  <pre><code>worker.list=worker1
  worker.worker1.type=ajp13
  worker.worker1.host=localhost
  worker.worker1.port=8009
  </code></pre>
  
  <p>My configuration is Apache 2.2.20, Tomcat 6, running on Mac Mini Server OS X Lion....</p>
  
  <p>If i try to access www.example.com, I correctly se my index.html page, but when I click on a button which is linked to another page or a Servlet or a JSP in my Project, this is the message:</p>
  
  <pre><code>404 Not Found Error
  Not Found
  
  The requested URL /MyAppName/RegistrationPage was not found on this server.
  
  Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2 mod_jk/1.2.30 Server at www.example.com Port 80
  </code></pre>
  
  <p>Moreover if a JSP is directly within MyAppName page (not within a subdirectory), it prints the code, the java engine doesn't interpret the code.</p>