0

Good day to all. I'll give you an example, I tried it

There are 2 entries for BalanceMember in /etc/hosts. Of course, don’t look at these virtual machines, it’s a black box. All requests return to 404 not found.

 ServerName service.test.com SSLProxyEngine on <Proxy "balancer://service"> BalancerMember https://service1.ng.com BalancerMember https://service2.ng.com </Proxy> ProxyPass "/" "balancer://service/" ProxyPassReverse "/" "balancer://service/" 

If I edit /etc/hosts and change the name from service1.ng.com to service.ng.com then change conf apache to this

 ServerName service.test.com SSLProxyEngine on <Proxy "balancer://service"> BalancerMember https://service.ng.com BalancerMember https://service2.ng.com </Proxy> ProxyPass "/" "balancer://service/" ProxyPassReverse "/" "balancer://service/" 

One request out of 2 will return 200 OK. Do you understand, right? But I can’t understand. What does the proxy send to one of the balancers, that everything works. Well, or after the balancer, I don’t know.

Thank you in advance for your response.

2 Answers 2

0

This looks like you might need either a different configuration on your backends (service1,2) to respond to requests coming to the host names service1,2 or a different setting for ProxyPreserveHost.

In standard setup, a ProxyPass will replace the Host header of the request when it's proxied to the backends. This is because the backend itself might have several VirtualHosts configured and needs to be able to figure out which one to use. This can cause a problem because at that point you don't know anymore what the original requested hostname was.

It is perfectly valid to configure all your backends to respond to the original server name, because that will cause less trouble with, for example, links they put in pages, which will not accidentally contain https://service1/ or somesuch, but you need to set ProxyPreserveHost on to tell your frontend httpd to leave the request's Host header alone.

3
  • Do I understand correctly. What is the best configuration on my part to do next ServerName service.ng.com and ProxyPreserveHost on, for my case Commented Feb 1, 2024 at 8:05
  • Because with BalancerMember service.ng.com it works, not work with service1, service2, i'm agree about conf virtualhosts in porxypass Commented Feb 1, 2024 at 9:33
  • If you have good reasons to have all backends identical, and most people do, ProxyPreserveHost on is the easiest way to go. (The only reason not to I can think of are weird monitoring border cases that wouldn't apply to you unless you have dozens or hundreds of these cases.) Commented Feb 1, 2024 at 9:59
0
<Location "/"> ProxyPass "https://service.ng.com/" ProxyPassReverse "https://service.ng.com/" AllowOverride None Order Deny,Allow Deny from All Allow from All </Location> 

This block solved my problem. Thank you.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.