ProxyPassReverse is used for rewriting response headers related only to 
redirection.   As per the docs, it affects only “Location”, “Content-Location” 
and “URI” headers on HTTP redirect responses.

The example they give is helpful (although cluttered with other concepts).  
Here is a more crystalized version of the example and a protocol exchange for 
clarity.


ProxyPass         "/mirror/foo/" "http://backend.example.com/";
ProxyPassReverse  "/mirror/foo/" "http://backend.example.com/";
If the backend server uses a redirect to some other location on the same 
backend server, the reverse-proxy rewrites the ‘redirect headers’ according to 
the ProxyPassReverse directive.

Let’s say the backend.example.com uses the location 
header<https://en.wikipedia.org/wiki/HTTP_location> to redirect a request 
http://backend.example.com/bar to http://backend.example.com/quux.  The 
end-to-end protocol exchange looks something like (caveat: written without 
validating):

Client Request:

GET /mirror/foo/bar HTTP/1.1

Host: example.com



Reverse Proxy rewrites it to the backend (courtesy of the ProxyPass directive):

GET /bar HTTP/1.1

Host: backend.example.com



Backend Server responds with a redirect using the location 
header<https://en.wikipedia.org/wiki/HTTP_location>:

HTTP/1.1 302 Found

Location: http://backend.example.com/quux

Reverse Proxy Intervenes (courtesy of the ProxyPassReverse directive) and 
rewrites the Location header to be:

HTTP/1.1 302 Found

Location: http://example.com/mirror/foo/quux

The client then reissues the request to the Location 
http://example.com/mirror/foo/quux and the Reverse Proxy forwards it onto 
http://backend.example.com/quux.

Matt.


From: Ananya Dey [mailto:ananyadey...@gmail.com]
Sent: Tuesday, 29 January 2019 9:13 PM
To: users@httpd.apache.org
Subject: [users@httpd] Use of ProxyPassReverse

Hi all,

I am trying to connect my Apache webserver with my backend tomcat server. I am 
using ProxyPass to do the same. Is there a need to put ProxyPassReverse also 
along with it? I am not able to understand the working functionality of the two 
in depth. Could someone please elaborate on the same .

Thanks
Ananya

Reply via email to