Apache - Reverse Proxy and HTTP 302 status message

前端 未结 4 731
失恋的感觉
失恋的感觉 2021-02-05 22:36

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://intern

4条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 23:00

    The AskApache article is quite helpful, but in practice I found a combination of Rewrite rules and ProxyPassReverse to be more flexible. So in your case I'd do something like this:

        
           ServerName www.example.com
    
           ProxyPassReverse /app1/some-path/ http://internal1.example.com/some-path/
           RewriteEngine On
           RewriteRule /app1/(.*)   http://internal1.example.com/some-path$1 [P]
    
           ...
        
    

    I like this better because it gives you finer-grained control over the paths you're proxying for the internal server. In our case we wanted to expose only part of third-party application. Note that this doesn't address hard-coded links in HTML, which the AskApache article covers.

    Also, note that you can have multiple ProxyPassReverse lines:

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

    I mention this only because another third-party app we were proxying was sending out redirects that didn't include their internal host name, just a different port.

    As a final note, keep in mind that Firebug is extremely useful when debugging the redirects.

提交回复
热议问题