2024-10/conf/kapitel/kapitel_13.conf
2024-10-18 14:50:48 +02:00

137 lines
4.2 KiB
Plaintext

##### Kapitel 13
### Web-Worker Definition
<VirtualHost 172.31.31.111:80>
DocumentRoot /usr/local/apache2/htdocs-webworker1.sv
ServerName webworker1.sv
DirectoryIndex index.php index.html
CustomLog logs/webworker1-access.log combined
ErrorLog logs/webworker1-error.log
</VirtualHost>
<VirtualHost 172.31.31.112:80>
DocumentRoot /usr/local/apache2/htdocs-webworker2.sv
ServerName webworker2.sv
DirectoryIndex index.php index.html
CustomLog logs/webworker2-access.log combined
ErrorLog logs/webworker2-error.log
</VirtualHost>
### Loadbalancer pen
# % pen -f -l /tmp/pen.log 172.31.31.113:8888 172.31.31.111:80 172.31.31.112:80
### Balancer plus Manager
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
# BalancerPersist On
<VirtualHost 172.31.31.105:80>
ServerName revproxy-manager.sv
<Location /balancer-manager>
SetHandler balancer-manager
Require ip 172.31.31.0/24
</Location>
<Proxy balancer://webworker/>
BalancerMember http://172.31.31.111
BalancerMember http://172.31.31.112
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://webworker/
CustomLog logs/revproxy-manager_access.log combined
ErrorLog logs/revproxy-manager_error.log
</VirtualHost>
### Weiteres: Balancer Sticky
# Testen (mehrfach hintereinander!) mit
# % curl -i http://revproxy-sticky.sv
# % curl -i --cookie "ROUTEID=.w2; path=/" http://revproxy-sticky.sv
#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
# BalancerPersist On
<VirtualHost 172.31.31.105:80>
ServerName revproxy-sticky.sv
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Location /balancer-manager>
SetHandler balancer-manager
Require ip 172.31.31.0/24
</Location>
<Proxy balancer://webworker/>
BalancerMember http://172.31.31.111 route=w1
BalancerMember http://172.31.31.112 route=w2
ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass /balancer-manager !
ProxyPass / balancer://webworker/
CustomLog logs/revproxy-sticky_access.log combined
ErrorLog logs/revproxy-sticky_error.log
</VirtualHost>
### Tomcat Loadbalancer mit Sticky-Sessions
<VirtualHost 172.31.31.106:80>
ServerName tomcat-lb.sv
DocumentRoot /usr/share/tomcat10-examples/
<Proxy balancer://tomcat-ajp>
BalancerMember ajp://localhost:8009 route=t0
BalancerMember ajp://192.168.1.101:8009 route=t1
BalancerMember ajp://192.168.1.102:8009 route=t2 status=+H
BalancerMember ajp://192.168.1.103:8009 route=t3 status=+R
ProxySet stickysession=JSESSIONID|jsessionid scolonpathdelim=On
</Proxy>
<Proxy balancer://tomcat-ws>
BalancerMember ws://localhost:8080 route=t0
BalancerMember ws://192.168.1.101:8080 route=t2
BalancerMember ws://192.168.1.102:8080 route=t3 status=+H
BalancerMember ws://192.168.1.103:8080 route=t4 status=+R
ProxySet stickysession=JSESSIONID|jsessionid scolonpathdelim=On
</Proxy>
RewriteEngine On
RewriteRule ^/examples/(.*)\.jsp(x?)$ balancer://tomcat-ajp/examples/$1.jsp$2 [P,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule ^/examples/websocket/(.*)$ balancer://tomcat-ws/examples/websocket/$1 [P,L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule ^/examples/(.*)$ ajp://tomcat-ajp/examples/$1 [P,L]
<Directory /usr/share/tomcat10-examples/>
Require all granted
Options Indexes
</Directory>
CustomLog logs/tomcat-lb_access.log combined
ErrorLog logs/tomcat-lb_error.log
</VirtualHost>