title: apache 2 proxypassreverse appends virtualhost port
body: <p>I have been trying to setup a reverse proxy using apache 2 mod_proxy and the proxypass &amp; proxypassreverse directives.</p>
  
  <p>I am installing WSO2 Identity Server and wish to access that app using a url such as the following . </p>
  
  <pre><code>hxxp://myserver.domain.com/wso2/
  </code></pre>
  
  <p>The <code>myserver.domain.com</code> is accessible on the internet</p>
  
  <p>Internally on my network I have set up a virtualhost running in my apache2 configuration with the following parameters:</p>
  
  <p>For various reasons, port 80 is unavailable and the virtualhost must stay as :8080.</p>
  
  <p>Finally, here is my virtual host configuration</p>
  
  <pre><code>&lt;VirtualHost *:8080&gt;
  
    &lt;Location /wso2/&gt;
      ProxyPass hxxps://internal.wso2.node:9443/
      ProxyPassReverse hxxs://internal.wso2.node:9443/
    &lt;/Location&gt;
  
   ProxyVia On
   ProxyPreserveHost Off
   ProxyAddHeaders Off
   ProxyRequests Off
   SSLProxyEngine On
   SSLProxyCheckPeerCN Off
  
   &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The issue:</p>
  
  <p>I can use my web browser ( Firefox/Chrome) to request the <a href="http://myserver.domain.com/wso2/" rel="nofollow">http://myserver.domain.com/wso2/</a> resource. In my log files I see that the request does hit the apache server and the virtualhost catches the /wso2/ location. </p>
  
  <p>It passes through the proxy and lands on the internal.wso2.node server. however, the product WSO2 IS preforms several redirects which, in the log files I see it requesting the resource with the port appended. </p>
  
  <p>Here is the request flow</p>
  
  <pre><code>  hxxp://myserver.domain.com/wso2/  -&gt; hxxps://internal.wso2.node:9443/
    REDIRECT x3
    hxxps://internal.wso2.node:8080/carbon -&gt; 
    hxxps://internal.wso2.node:8080/carbon/admin/login.jsp
  
    Back to my web browser
    hxxp://myserver.domain.com:8080/wso2/carbon/admin/login.jsp
  </code></pre>
  
  <p>For some reason the apache response back appends its virtual host to the url I am requesting.</p>
  
  <p>If I remove the port:8080 and request again the full url it will access the resource fine. However any attempt to access using only <a href="http://myserver.domain.com/wso2/" rel="nofollow">http://myserver.domain.com/wso2/</a> will result in redirects and the port appended.</p>