title: How to redirect Apache 2.2 on Windows to Tomcat (same machine)
body: <p>I have spent quite some time trying to figure out something apparentaly pretty trivial, but my lack of knowledge in Apache/Tomcat isn't making this easy for me.</p>
  
  <p>I was asked to redirect a request coming on port 80 (Apache) to port 8080 (Tomcat.. and when that will work, to an app). </p>
  
  <p>Before I changed anything, localhost:80 would show "It works" and locahost:8080 the Apache welcome page.</p>
  
  <p>I did the following changes : </p>
  
  <ul>
  <li>uncommented LoadModule proxy_module modules/mod_proxy.so &amp; LoadModule proxy_http_module modules/mod_proxy_http.so from the httpd.conf file</li>
  <li>uncommented Include conf/extra/httpd-vhosts.conf, always in httpd.conf</li>
  </ul>
  
  <p>In httpd-vhosts.conf, I added : </p>
  
  <p><code>&lt;VirtualHost *:80&gt;
      ServerName localhost
      ProxyRequests Off
      ProxyPreserveHost On
      ProxyPass /  http://localhost:8080
      ProxyPassReverse / http://localhost:8080
  &lt;/VirtualHost&gt;</code></p>
  
  <p>But when I try <a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>, I do arrive on Apache welcome page, but all css styling, images, are missing : </p>
  
  <p><a href="https://i.stack.imgur.com/y6h8C.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y6h8C.jpg" alt="Apache welcome page"></a></p>
  
  <p>I have an idea why it is not working : when I inspect my page, and look at the header i see that the link to the favicon for example is <a href="http://mydomain/myApp/images/favicon.ico" rel="nofollow noreferrer">http://mydomain/myApp/images/favicon.ico</a>, but if I copy paste that link, I will of course not find the favicon because it is not on Apache, but Tomcat (if that makes any sense). If I add the port to the URL, then it works : <a href="http://mydomain:8080/myApp/images/favicon.ico" rel="nofollow noreferrer">http://mydomain:8080/myApp/images/favicon.ico</a></p>
  
  <p>Has this anything to do with the problem stated here : <a href="https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy">https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy</a> ? </p>
  
  <blockquote>
    <p>This is because the tomcat response headers will contain the proxy headers (i.e. the Location header is <a href="http://localhost/WebApp" rel="nofollow noreferrer">http://localhost/WebApp</a> rather than <a href="http://localhost:8080/WebApp" rel="nofollow noreferrer">http://localhost:8080/WebApp</a>) because ProxyPreserveHost is switched On</p>
  </blockquote>
  
  <p>So I switched it to Off : </p>
  
  <p><code>&lt;VirtualHost *:80&gt;
      ServerName localhost
      ProxyRequests Off
      ProxyPreserveHost Off
      ProxyPass /  http://localhost:8080
      ProxyPassReverse / http://localhost:8080
  &lt;/VirtualHost&gt;</code></p>
  
  <p>But the page still will not show correctly. </p>
  
  <p>Thank you for your input.</p>