Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache - Reverse Proxy and HTTP 302 status message

My team is trying to setup an Apache reverse proxy from a customer's site into one of our web applications.

http://www.example.com/app1/some-path maps to http://internal1.example.com/some-path

Inside our application we use struts and have redirect = true set on certain actions in order to provide certain functionality. The 302 status messages from these re-directs cause the user to break out of the proxy resulting in an error page for the end user.

HTTP/1.1 302 Found Location: http://internal.example.com/some-path/redirect

Is there any way to setup the reverse proxy in apache so that the redirects work correctly?

http://www.example.com/app1/some-path/redirect

like image 997
Rob Avatar asked Oct 09 '08 22:10

Rob


2 Answers

There is an article titled Running a Reverse Proxy in Apache that seems to address your problem. It even uses the same example.com and /app1 that you have in your example. Go to the "Configuring the Proxy" section for examples on how to use ProxyPassReverse.

like image 144
Kevin Hakanson Avatar answered Sep 20 '22 12:09

Kevin Hakanson


Basically, ProxyPassReverse should take care of rewriting the Location header for you, as Kevin Hakanson pointed out.

One pitfall I have encountered is missing the trailing slash in the url argument. Make sure to use:

ProxyPassReverse / http://internal1.example.com/some-path/

(note the trailing slash!)

like image 41
philippn Avatar answered Sep 17 '22 12:09

philippn