2

Does anyone have some tips or an example for how to configure this sort of reverse proxy arrangement on Apache Http Server 2.2? I support a Java web application that we develop in multiple environments. By multiple environments, I mean that we have several instances of a Tomcat server running on the same host at different ports: development = 9443, QA = 10443, production = 11443

Java web applications are designed so that you can host multiple apps on one server: each application can be reached at its own root context. If you're not familiar with the technology, basically, that means that all of my app's pages are behind the /myapp in https://myhost.mydomain.com/myapp.

Java web apps also require the use of cookies to maintain session state, so any reverse proxying solution needs to make sure that the proxied host name is translated back to the outside host name.

We currently have the production Tomcat instance shared to the internet through an Apache reverse proxy that proxies https://public.mydomain.com/myapp to https://tomcatserver.mydomain.com:11443/myapp. We would like to open up the QA Tomcat instance to the internet so that beta testers can get to it, but the https://publicserver.mydomain.com/myapp URL is already set up to go to production. So we're trying to set up a second proxy that maps https://publicserver.mydomain.com/beta to https://tomcatserver.mydomain.com:10443/myapp.

Here's what I've tried so far, but it's not working. Both addresses (/myapp and /beta) always end up at the production Tomcat instance.

<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName public.mydomain.com
    ServerAlias public

    # Proxy to production environment on tomcatserver
    ProxyPass         /myapp/  https://tomcatserver.mydomain.com:11443/myapp/
    ProxyPassReverse  /myapp/  https://tomcatserver.mydomain.com:11443/myapp/
    <location /myapp/>
        SSLRequireSSL On
        SetOutputFilter              proxy-html
        ProxyPassReverseCookieDomain tomcatserver.mydomain.com    public.mydomain.com
        ProxyPassReverseCookiePath   /       /myapp/
        ProxyHTMLURLMap              /myapp  /myapp
    </location>

    # Proxy to QA environment on tomcatserver
    ProxyPass         /beta/  https://tomcatserver.mydomain.com:10443/myapp/
    ProxyPassReverse  /beta/  https://tomcatserver.mydomain.com:10443/myapp/
    <location /beta/>
        SSLRequireSSL On
        SetOutputFilter              proxy-html
        ProxyPassReverseCookieDomain tomcatserver.mydomain.com    public.mydomain.com
        ProxyPassReverseCookiePath   /      /myapp/
        ProxyHTMLURLMap              /beta  /myapp
    </location>
</VirtualHost>
5
  • Is the client browser being sent a 30x redirect response? May 3, 2013 at 5:04
  • What is in your apache logs?
    – Jenny D
    May 3, 2013 at 9:40
  • I went through the login with Firebug running, and interestingly enough, I found that httpd is sending me to the right URL. Upon entering my userid and pw on the web app login page and hitting submit, I'm getting redirected to the wrong server instance. So I think that the problem is either in my login page Java code or in some http header that I'm not rewriting properly with the reverse proxy config.
    – msinatl
    May 6, 2013 at 20:55
  • 192.168.1.228 - - [06/May/2013:16:44:22 -0400] "GET /beta/ HTTP/1.1" 302 20 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0" 192.168.1.228 - - [06/May/2013:16:44:25 -0400] "GET /beta/auth/login?targetController=home HTTP/1.1" 200 2279 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0" 192.168.1.228 - - [06/May/2013:16:44:30 -0400] "GET /myapp/css/main.css HTTP/1.1" 200 4765 "https://public.mydomain.com/beta/auth/login?targetController=home" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
    – msinatl
    May 6, 2013 at 21:21
  • 192.168.1.228 - - [06/May/2013:16:45:02 -0400] "POST /myapp/auth/signIn HTTP/1.1" 302 20 "https://public.mydomain.com/beta/auth/login?targetController=home" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0" 192.168.1.228 - - [06/May/2013:16:45:04 -0400] "GET /myapp/ HTTP/1.1" 200 4183 "https://public.mydomain.com/beta/auth/login?targetController=home" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
    – msinatl
    May 6, 2013 at 21:23

0

You must log in to answer this question.

Browse other questions tagged .