0

I'd like to configure apache so that http://my-domain.com/myapp serves a Python webapp running in CherryPy on a backend server.

Here's what's in the vhost:

    RewriteRule ^/myapp/?(.*) http://backend-server:8000/$1 [P]
    ProxyPassReverse /myapp/ http://backend-server:8000/

When I trace the request/response, I see:

GET /myapp HTTP/1.1
Host: my-domain.com

And then:

HTTP/1.1 303 See Other
Date: Thu, 15 Sep 2011 21:46:35 GMT
Server: CherryPy/3.1.2
Content-Type: text/html;charset=utf-8
Location: http://my-domain.com/somwhere-else/

As you can see, the CherryPy webapp sends a 303 redirect to /somewhere-else/

Any ideas why the Apache ProxyPassReverse doesn't transform the Location to http://my-domain.com/myapp/somewhere-else?

Upgradingdave
  • 241
  • 5
  • 13

3 Answers3

1

Your source location is /myapp, while your ProxyPassReverse is for /myapp/; context of the proxied location doesn't match, so the ProxyPassReverse doesn't apply.

Why the mod_rewrite proxy? This should accomplish the same, and have no trailing slash consistency issues:

ProxyPass /myapp http://backend-server:8000
ProxyPassReverse /myapp http://backend-server:8000
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Thanks much for the reply. I tried your suggestion, but, unfortunately, I'm seeing the same response. Perhaps I'm missing some other Apache directive? I'll keep digging.... – Upgradingdave Sep 15 '11 at 23:41
  • @Dave CherryPy might be getting sensitive about the `Host:` header - try adding `ProxyPreserveHost on`. Still, Apache should catch and translate that redirect, unless it doesn't think it should; is there anything different about the new URL versus the old? Host name (is there a `www`?), port, protocol - any difference in these things to the original request will cause Apache to leave the `Location:` header alone. – Shane Madden Sep 16 '11 at 00:47
1

I had same problem and fix it as follow:

For some reason both context path must be the same so, I mod my application context path to be the equal (note extra "/" on passResever)

    ProxyPass               /jira           http://192.168.1.30:8080/jira
    ProxyPassReverse        /jira/          http://192.168.1.30:8080/jira
Armando
  • 11
  • 1
0

The problem is that the backend app serves back a Location header with the public name "my-domain.com", so ProxyPassReverse doesn't recognize it. The backend server should not know the public name (frontend name), it should only know itself by the name "backend-server".

Leif John
  • 181
  • 1
  • 6