以下内容为原创,转载请注明出处!

centos Apache2 httpd配置django项目,负载均衡,会话保持

#<VirtualHost *:8082>
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
WSGIScriptAlias / /home/dp/hue-cdh6.0.0-release/desktop/core/src/desktop/wsgi.py
WSGIPythonPath /home/dp/hue-cdh6.0.0-release/desktop/core/src/desktop:/home/dp/hue-cdh6.0.0-release/build/env/lib/python2.7/site-packages
WSGIDaemonProcess hue_httpd_project home=/home/dp/hue-cdh6.0.0-release python-path=/home/dp/hue-cdh6.0.0-release/desktop/core/src/desktop:/home/dp/hue-cdh6.0.0-release/build/env/lib/python2.7/site-packages threads=30
WSGIProcessGroup hue_httpd_project
<Directory /home/dp/hue-cdh6.0.0-release/desktop/core/src/desktop>
<Files wsgi.py>
Order Deny,Allow
# If apache 2.4
Require all granted
</Files>
</Directory>
# 写入routeid来保持会话
Header add Set-Cookie "routeId=.%{BALANCER_WORKER_ROUTE}e;path=/" env=BALANCER_ROUTE_CHANGED
# 配置负载均衡
ProxyRequests Off
# 配置负载均衡web管理界面
<Location /balancer-manager>
SetHandler balancer-manager
order Deny,Allow 
Allow from all 
Allow from localhost 
</Location>
ProxyPass /balancer-manager !
#轮询式负载均衡
<Proxy "balancer://mycluster">
BalancerMember http://hue-test158.dp.jpushoa.com route=hue158
BalancerMember http://hue-test166.dp.jpushoa.com route=hue166
</Proxy>
ProxyPass / balancer://mycluster/ stickysession=routeId
# log打印
ErrorLog   /etc/httpd/logs/hue.error.log
LogLevel warn
#</VirtualHost>



apache部署服务器请参照:https://www.520pf.cn/article/22.html

apache https证书请参照:https://www.520pf.cn/article/102.html