1

I have been trying to setup a reverse proxy using apache 2 mod_proxy and the proxypass & proxypassreverse directives.

I am installing WSO2 Identity Server and wish to access that app using a url such as the following .

hxxp://myserver.domain.com/wso2/

The myserver.domain.com is accessible on the internet

Internally on my network I have set up a virtualhost running in my apache2 configuration with the following parameters:

For various reasons, port 80 is unavailable and the virtualhost must stay as :8080.

Finally, here is my virtual host configuration

<VirtualHost *:8080>

  <Location /wso2/>
    ProxyPass hxxps://internal.wso2.node:9443/
    ProxyPassReverse hxxs://internal.wso2.node:9443/
  </Location>

 ProxyVia On
 ProxyPreserveHost Off
 ProxyAddHeaders Off
 ProxyRequests Off
 SSLProxyEngine On
 SSLProxyCheckPeerCN Off

 </VirtualHost>

The issue:

I can use my web browser ( Firefox/Chrome) to request the http://myserver.domain.com/wso2/ resource. In my log files I see that the request does hit the apache server and the virtualhost catches the /wso2/ location.

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.

Here is the request flow

  hxxp://myserver.domain.com/wso2/  -> hxxps://internal.wso2.node:9443/
  REDIRECT x3
  hxxps://internal.wso2.node:8080/carbon -> 
  hxxps://internal.wso2.node:8080/carbon/admin/login.jsp

  Back to my web browser
  hxxp://myserver.domain.com:8080/wso2/carbon/admin/login.jsp

For some reason the apache response back appends its virtual host to the url I am requesting.

If I remove the port:8080 manually and request again the full url in the browser it will access the resource fine. However any attempt to access using only http://myserver.domain.com/wso2/ will result in redirects and the port appended.

1

As far as you are changing also the URI when doing ProxyPass probably you will need to rewrite also the cookie

<VirtualHost *:8080>
    ServerName myserver.domain.com
    ProxyVia On
    ProxyPreserveHost Off
    ProxyAddHeaders Off
    ProxyRequests Off
    SSLProxyEngine On
    SSLProxyCheckPeerCN Off
    ProxyPass /wso2/ https://internal.wso2.node:9443/
    ProxyPassReverse /wso2/ http://myserver.domain.com:8080/
    ProxyPassReverseCookiePath / /wso2
    ProxyPassReverseCookieDomain internal.wso2.node myserver.domain.com
  </VirtualHost>

Usually ProxyPassReverse is a bit tricky (for me at least) and probably you will need ProxyPassReverseCookiePath, and just in case ProxyPassReverseCookieDomain (to rewrite your cookies to maintain the session).

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.