Score:0

Load balancing apache 2.4 ProxyPass configuration meaning

in flag

I'm studying apache 2.4 and I've found this configuration as example. What I don't understand is the definition of ProxyPass, they have defined "balancer://cluster/example1/api" but in the Proxy directive there is only "balancer://cluster".

What they have done in this configuration? Can anyone explain me with some pratice example?

<VirtualHost *:10000> 
    ProxyRequests Off
    ProxyTimeout 300
    ProxyPreserveHost On
    ProxyVia On
    <Proxy balancer://cluster>
        BalancerMember http://localhost:8888         
        ProxySet lbmethod=bytraffic
    </Proxy>    
    ProxyPass /content/sub1 balancer://cluster/example1/api  
</VirtualHost>
Martin avatar
kz flag
This directive makes apache act as a [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy), which means any request to ```/content/sub1``` or below will not be served with a local html document, but will be passed onto the backend server defined in that ```ProxyPass``` directive.
Luca avatar
in flag
but it's referring to the balancer as the second argument "balancer://cluster/example1/api ".
Martin avatar
kz flag
well, instead of pointing the reverse proxy to a fixed backend server, you can use it as load balancer: the first incoming request is forwarded to backend server 1, the second request to backend server 2, and so on. This way, each backend server must only be able to handle a part of the overall load. In this case, the balancing algorithm is obviously the number of bytes received by each backend server.
Luca avatar
in flag
Thank you Martin for you explanation, I really appreciate. But what I don't understand is why in ProxyPass they put "balancer://cluster/example1/api " when in the Proxy directive they have <Proxy balancer://cluster>? How is the apache behaviors?
Luca avatar
in flag
I mean, what's happen when they put as second parameter of ProyPass "balancer://cluster/example1/api" instead of "balancer://cluster" as define in the <Proxy> directive?
Martin avatar
kz flag
that is the path you are accessing... any URI like ```http://www.example.com/questions/3456/my-document``` are build made of the access scheme (http), the server name (www.example.com), and the path your browser is trying to access ( /questions/3456/my-document ). This is also true for load-balanced servers, as they must know which document to deliver!
Luca avatar
in flag
Ohhh ok, now I see, I thought that second parameter must match the the url in the proxy directive
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.