2022年12月7日 星期三

Debian 11 Apache2 reverse proxy balance 筆記

載入相關模組
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
sudo a2enmod lbmethod_bytraffic
sudo a2enmod headers

編輯 /etc/apache2/sites-enabled/000-default.conf 

<VirtualHost *:80>
ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html     

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

ProxyRequests Off
ProxyPreserveHost On
<Proxy balancer://myset>
    BalancerMember http://192.168.1.1:80/aa
    BalancerMember http://192.168.1.2:80/aa
   #ProxySet lbmethod=byrequests
    ProxySet lbmethod=bytraffic
</Proxy>

ProxyPass "/aa"  "balancer://myset/"
ProxyPassReverse "/aa"  "balancer://myset/"

</VirtualHost>

沒有留言: