[TUTORIAL] Config Dump: Apache Load Balancer (Fail-Over) and Reverse Proxy

Jul 24, 2023
3
3
3
config dump from our running and working apache reverse proxy with load balancer config in case someone needs it.

needed apache modules:
Code:
proxy_http
proxy_balancer
lbmethod_byrequests

vhost config:

Code:
<VirtualHost *:443>

    ServerName PROXMOX.DOMAIN.TLD

    ServerSignature Off
    TraceEnable Off

    LogLevel Warn
    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined


    <Location /*>

        Order allow,deny
        Allow from 192.168.0.0/16

    </Location>


    <IfModule mod_proxy_balancer.c>

    <Proxy balancer://proxmox>
        BalancerMember https://PROXMOX-1.DOMAIN.TLD:8006
        BalancerMember https://PROXMOX-2.DOMAIN.TLD:8006 status=+H
        ProxySet lbmethod=byrequests
    </Proxy>

    </IfModule>


    <IfModule mod_proxy.c>

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyErrorOverride On

    SSLProxyEngine On

    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1

    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off

    ProxyPass "/" "balancer://proxmox/"
    ProxyPassReverse "/" "balancer://proxmox/"

    </IfModule>


    <IfModule mod_ssl.c>

    SSLCertificateFile /etc/letsencrypt/live/PROXMOX.DOMAIN.TLDfullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/PROXMOX.DOMAIN.TLDprivkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

    </IfModule>


</VirtualHost>

option "status=+H" in BalancerMember number 2 (or any following servers) enables fail-over. this host(s) are only used if the none "status=+H" server fails to answer.
 
Last edited:
Thanks for sharing this!

If it works fine - I think the tag '[TUTORIAL]' would be more fitting here than '[SOLVED]' (you can change that by clicking 'Edit Thread' above your top post.

Thanks again!