title: Configure Tomcat8 behind Apache with HTTPS
body: <p>I have Tomcat 8 installed in my server in port 8080 that I am exposing with a secured Apache (using Proxy Pass).</p>
  
  <p>Here is my Apache configuration:</p>
  
  <pre><code>&lt;VirtualHost *:443&gt;
      ServerName myserver.com
  
      ProxyRequests Off
      ProxyPreserveHost On
  
      ProxyPass           /odata/    http://172.31.36.251:8080/
      ProxyPassReverse    /odata/    http://172.31.36.251:8080/
  
      &lt;Proxy *&gt;
          allow from all
      &lt;/Proxy&gt;
  
      RequestHeader set X-Forwarded-Port 443
      RequestHeader set X-Forwarded-Scheme https
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Here is the Tomcat server.xml configuration</p>
  
  <pre><code>&lt;Connector port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443" 
              address="172.31.36.251" 
              proxyName="myserver.com" 
              scheme="https" proxyPort="443"  /&gt;
  </code></pre>
  
  <p>All works well until here. If I call my application:
  <a href="https://myserver.com/odata/D3a1593adae89/odata.svc/" rel="nofollow noreferrer">https://myserver.com/odata/D3a1593adae89/odata.svc/</a></p>
  
  <p>I get:</p>
  
  <pre><code>&lt;service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="https://myserver.com:443/D3a1593adae89/odata.svc/"&gt;
  &lt;workspace&gt;
  &lt;atom:title&gt;Default&lt;/atom:title&gt;
  &lt;collection href="Maintables"&gt;
  &lt;atom:title&gt;Maintables&lt;/atom:title&gt;
  &lt;/collection&gt;
  &lt;/workspace&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p><strong>The problem:</strong>  If you see the attribute <strong>xml:base</strong> in the result, Tomcat decorates the address with the port and I really don't know how to remove it. Also the address is wrong: It should be <a href="https://myserver.com:443/" rel="nofollow noreferrer">https://myserver.com:443/</a><strong>odata</strong>/D3a1593adae89/odata.svc/  . I been looking around and trying things like setting <em>proxyPort</em> to blank but nothing. I think this is related to broken links when using a reverse proxy as described at <a href="https://cwiki.apache.org/confluence/display/HTTPD/TomcatModProxyHTML" rel="nofollow noreferrer">https://cwiki.apache.org/confluence/display/HTTPD/TomcatModProxyHTML</a> . I tried some rewrites like:</p>
  
  <pre><code>ProxyHTMLURLMap http://172.31.33.105:8080 /odata
         RewriteEngine On
         RewriteRule ^/odata$ https://myserver.com/odata/ [R,L]
  </code></pre>
  
  <p>But I just cannot make it work. The xml:base should be <a href="https://myserver.com/odata/D3a1593adae89/odata.svc/" rel="nofollow noreferrer">https://myserver.com/odata/D3a1593adae89/odata.svc/</a></p>
  
  <p>Any idea is appreciated</p>