19

I have scanned through the internet and also stackoverflow and I'm still not sure of the purpose of proxypass and proxypassreverse.

Why do we need proxypass (instead of using mod_jk) for apache server to connect to tomcat?

2 Answers 2

27

The ProxyPassReverse is used to change the headers sent to Apache from a proxied app server, before Apache sends it to the browser.

For example, if the app sits on localhost:8080, it will respond with a redirect and location header of http://localhost:8080/new_path/, and Apache will take this and send it off to the browser. The browser will try to send a request to Page on localhost:8080 and receive an error.

ProxyPassReverse will intercept those headers, and rewrite them to match the Apache proxy server.

ProxyPass will create a reverse proxy. A reverse proxy (or gateway), appears to the client just like an ordinary web server. The client makes ordinary requests for content in the namespace of the reverse proxy. The reverse proxy then decides where to send those requests and returns the content as if it were itself the origin.

https://www.quora.com/Whats-the-difference-between-proxypassreverse-and-proxypass

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

2
  • Due to this ProxyPass setup, is it possible to install ssl on the apache server and have the apps listen on http (without ssl)? The browser will shoot requests in https to the server and the server will redirect them to the http client, same way back. Will the browser think it's on ssl and show a green lock? Sounds like a hassle to manage ssl on all applications on the server...
    – DFSFOT
    Jun 6, 2021 at 20:57
  • Could be concretized that it doesnt serve to allow changing any headers as it might sound from the wording "change the headers sent",but only exactly 1 type of headers,the redirection header/s Also the example might sound initially explanatory but it is not mention if its the example for using that directive (as one might expect)or not using it.It is more clear to somebody who already knows this exact behavior from apache documentation.In example is not mentioned usage,but what happens when the directive of interest is not used,what is not intuitive-one must imagine there a read between lines
    – FantomX1
    Aug 12, 2021 at 16:02
5

Nice link on SO:: apache to tomcat: mod_jk vs mod_proxy

1.One reason can be to use mod_proxy to include other servers while maintaining fancy URLs.

2.Other advantage can be that when you are using tomcat as server, the mod_proxy_ajp module has the ProxyPassReverseCookiePath directive, which allows you to map the session cookies of a Tomcat web application (other than the root application) into the root of a virtual host.

3.Mod_proxy simply redirects requests for certain URLs to another web server, so it typically requires no additional configuration on the application server.

Also, see http://www.humboldt.co.uk/2009/02/the-mystery-of-proxypassreverse.html

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.