szxnyc
szxnyc

Reputation: 2585

Apache ProxyPass Load Balance ALL URL's

Using Apache HTTP Server, how do I load balance all URL's, not just root "/" or some sub-directories under root like "/css", but absolutely everything to a balanced backend?

My config will only route the literal root URL "/" but other URL's are not covered, do I need to use a regex?

Relevant config:

<Proxy balancer://mycluster>
    BalancerMember https://server1:8443
    BalancerMember https://server2:8443
    ProxySet lbmethod=byrequests
</Proxy>

<VirtualHost _default_:443>
    SSLProxyEngine on
    ProxyPass "/" "balancer://mycluster"
    ProxyPassReverse "/" "balancer://mycluster"
</VirtualHost>

Apache access_log (notice /css receives a 500 response):

172.18.0.1 - - [10/May/2017:20:22:55 +0000] "GET / HTTP/1.1" 200 196
172.18.0.1 - - [10/May/2017:20:22:58 +0000] "GET /css HTTP/1.1" 500 528

Apache error_log:

[Wed May 10 20:22:58.607433 2017] [proxy:warn] [pid 9:tid 140682836559616] [client 172.18.0.1:35304] AH01144: No protocol handler was valid for the URL /css. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

Upvotes: 4

Views: 1424

Answers (1)

Daniel Ferradal
Daniel Ferradal

Reputation: 2900

ProxyPass / .... is enough to proxy everything, but make sure you match slashes, specifying "balancer://mycluster" is incorrect, and you need to match slashes back and forth, so if your origin ends in slash the target also ends in slash, plus in this case balancer://mycluster is really balancer://mycluster/

ProxyPass / balancer://mycluster/

Upvotes: 5

Related Questions