Question

I'm using Apache ProxyPass to pass some requests from my server (1) to another (2). This works fine for most requests, but when server 2 processes a POST request and sends a redirect header, this is passed right through to the client, who then applies the redirect on server 1 and thus gets a 404.

So what I'd like is that server 1 (the server with the ProxyPass) follows redirects on server 2 and passes the final page back to the client.

I'm sure this must be a very common scenario, but I can't seem to find the solution. I'm imagining something like a "follow_redirects" flag, similar as you would apply to a curl client, but I haven't found anything like that. Maybe what I'm trying to do isn't the purpose of ProxyPass?

Could someone point me in the right direction here?

Thanks, Chris

Was it helpful?

Solution

Check out the ProxyPassReverse directive. With this set Apache can intercept redirects and rewrite them so the client doesn't leave the proxy. This will not process redirects on the proxy, but it will at least make the client send the redirected request back to your server instead of leaving you.

OTHER TIPS

I found the Apache Traffic Server, which is a reverse-proxy made by Yahoo and given to the Apache foundation.

From this documentation:

Origin servers often send redirect responses back to browsers redirecting them to different pages. For example, if an origin server is overloaded, then it might redirect browsers to a less loaded server. Origin servers also redirect when web pages that have moved to different locations. When Traffic Server is configured as a reverse proxy, it must readdress redirects from origin servers so that browsers are redirected to Traffic Server and not to another origin server.

I haven't tried this yet, but there are packages for Debian, Ubuntu and CentOS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top