背景:
阅读新闻
Keepalive+Nginx搭建主从负载服务器
[日期:2012-09-16] 来源:Linux社区 作者:yijiaxin [字体:]
keepalive+nginx搭建主从负载服务器
keepalive配置文件 从:
! Configuration File for keepalived global_defs { notification_email { xuezm@yaoshi.com } notification_email_from xuezm@yaoshi.com smtp_server mail.yaoshi.com smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 mcast_src_ip 192.168.11.39 priority 80 advert_int 1 authentication { auth_type PASS auth_pass chtopnet } virtual_ipaddress { 192.168.11.208 } }keepalive 主:
!Configuration File for keepalived global_defs { notification_email { xuezm@yaoshi.com } notification_email_from xuezm@yaoshi.com smtp_server mail.yaoshi.com smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 51 mcast_src_ip 192.168.11.27 priority 100 advert_int 1 authentication { auth_type PASS auth_pass chtopnet } virtual_ipaddress { 192.168.11.208 } }nginx配置 :
user nobody nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; error_log logs/error.log debug; pid logs/nginx.pid; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; gzip_min_length 1k; gzip_buffers 6 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; # location / { # root html; # index index.html index.htm; # } error_page 404 /404.html; upstream { server 192.168.11.37:80; server 192.168.11.38:80; } server { listen 80; server_name 192.168.11.208; index index.htm index.html; #root /web/wwwroot; location / { proxy_pass ; proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; include proxy.conf; } log_format blog_test_com '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/blog_test_com; } }