ProxyPassMatch with ProxyPassReverse

后端 未结 1 1448
青春惊慌失措
青春惊慌失措 2021-02-05 12:00

Folks, We are trying to setup Apache reverse proxy for the following scenario:

  • Incoming requests take the form http://foo.com/APP/v1/main.html
相关标签:
1条回答
  • 2021-02-05 12:11

    You're close, try changing the regex a little to account for the version fragment:

    ProxyPassMatch ^/.*?/APP.*?/v[0-9]+/(.*)$ http://localhost:8080/AppContext/$1
    

    The ProxyPassReverse is mostly to ensure the rewriting on-the-fly of location header fields in the responses given by the proxied app. So when it returns a 301 redirect to, say, http://localhost:8080/AppContext/something, apache knows to change it to /APP/v1/something so information behind the proxy won't get exposed. Because you have a dynamic URL used in the reverse proxy, you have a few choices here. You can either send it to the HAProxy load balancer (not sure where that is for you), or you can just pick one and hope for the best. For example, if you have a load balancer at /APP/balancer/ which then sends requests to /APP/v1/, /APP/v2/, /APP/v3/, etc. Then you can do this:

    ProxyPassReverse /APP/balancer http://localhost:8080/AppContext
    

    Otherwise, you can just point it to one and hope for the best:

    ProxyPassReverse /APP/v1 http://localhost:8080/AppContext
    
    0 讨论(0)
提交回复
热议问题