Apache loadbalance multiple DNS with custom params to slave servers

Well, I have setup an LB with apache2, behind it, there a project (ZF2 PHP), that is an Ecommerce.

I intend to have many DNS's from clients, and all of them pointing to my LB, and dispatching this requests, but my problem, is between LB and slaves servers, there's a way to me identity from which DNS, that request is?

Today I have this

<VirtualHost *:80>
    ServerName client1.com
    ServerAlias www.client1.com

    ProxyRequests Off
    <Proxy \*>
        Order deny,allow
        Deny from all
    </Proxy>

    <Proxy balancer://clusterA>
    BalancerMember http://http1.mysubdomain.com/10
    BalancerMember http://http2.mysubdomain.com/10
    Order allow,deny
    Allow from all
    </Proxy>
    ProxyPass / balancer://clusterA/
</VirtualHost>

<VirtualHost *:80>
    ServerName client2.com
    ServerAlias www.client2.com

    ProxyRequests Off
    <Proxy \*>
        Order deny,allow
        Deny from all
    </Proxy>

    <Proxy balancer://clusterB>
    BalancerMember http://http1.mysubdomain.com/20
    BalancerMember http://http2.mysubdomain.com/20
    Order allow,deny
    Allow from all
    </Proxy>
    ProxyPass / balancer://clusterB/
</VirtualHost>

This way, if access website from client 1 (client1.com), my project will know that he's ID is 10, and if it's from (client2.com) will be 20.

And that kinda works, but I'm having a hard time to control routes and paths (including 'public/' content inside the project.

Any tips/ideas? Thanks

0
задан 3 May 2018 в 23:11
2 ответа

Для проверки, на какой виртуальный хост был отправлен запрос, необходимо использовать переменную PHP $ _ SERVER ['SERVER_NAME'] .

0
ответ дан 5 December 2019 в 06:04

Ну, бывает, что мне просто нужно посмотреть свои заголовки, когда я получаю доступ через LB, есть изменение в заголовках, которые идут с X-Forwarded-Server которые указывают, откуда пришел DNS. В этом случае я использую метод getallheaders () из PHP.

0
ответ дан 5 December 2019 в 06:04

Теги

Похожие вопросы