Apache HTTPD 配置

  1. Header add Set-Cookie "SERVERID=sticky.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
  2. <Proxy "balancer://nodes_polling">
  3. BalancerMember "http://app01:3000" route=app01
  4. BalancerMember "http://app02:3000" route=app02
  5. BalancerMember "http://app03:3000" route=app03
  6. ProxySet stickysession=SERVERID
  7. </Proxy>
  8. <Proxy "balancer://nodes_ws">
  9. BalancerMember "ws://app01:3000" route=app01
  10. BalancerMember "ws://app02:3000" route=app02
  11. BalancerMember "ws://app03:3000" route=app03
  12. ProxySet stickysession=SERVERID
  13. </Proxy>
  14. RewriteEngine On
  15. RewriteCond %{HTTP:Upgrade} =websocket [NC]
  16. RewriteRule /(.*) balancer://nodes_ws/$1 [P,L]
  17. RewriteCond %{HTTP:Upgrade} !=websocket [NC]
  18. RewriteRule /(.*) balancer://nodes_polling/$1 [P,L]
  19. ProxyTimeout 3

例子