keepalive + nginx 메 인 부하 서버 구축

keepalive + nginx 메 인 부하 서버 구축
keepalive 프로필 부터:
 
   
   
   
   
  1. ! Configuration File for keepalived 
  2. global_defs { 
  3.    notification_email { 
  4.    [email protected] 
  5.         } 
  6.    notification_email_from [email protected] 
  7.    smtp_server mail.yaoshi.com 
  8.    smtp_connect_timeout 30 
  9.    router_id LVS_DEVEL 
  10. vrrp_instance VI_1 { 
  11.     state MASTER 
  12.     interface eth0 
  13.     virtual_router_id 51 
  14.     mcast_src_ip 192.168.11.39 
  15.     priority 80 
  16.     advert_int 1 
  17.     authentication { 
  18.         auth_type PASS 
  19.         auth_pass chtopnet 
  20.     } 
  21.     virtual_ipaddress { 
  22.         192.168.11.208 
  23.     } 

keepalive 주:
 
   
   
   
   
  1. !Configuration File for keepalived 
  2. global_defs { 
  3.    notification_email { 
  4.    [email protected] 
  5.         } 
  6.    notification_email_from [email protected] 
  7.    smtp_server mail.yaoshi.com 
  8.    smtp_connect_timeout 30 
  9.    router_id LVS_DEVEL 
  10. vrrp_instance VI_1 { 
  11.     state MASTER 
  12.     interface eth0 
  13.     virtual_router_id 51 
  14.     mcast_src_ip 192.168.11.27 
  15.     priority 100 
  16.     advert_int 1 
  17.     authentication { 
  18.         auth_type PASS 
  19.         auth_pass chtopnet 
  20.     } 
  21.     virtual_ipaddress { 
  22.         192.168.11.208 
  23.     } 

nginx 설정:
 
   
   
   
   
  1. user  nobody nobody; 
  2. worker_processes  1; 
  3.  
  4. #error_log  logs/error.log; 
  5. #error_log  logs/error.log  notice; 
  6. error_log  logs/error.log  debug; 
  7.  
  8. pid        logs/nginx.pid; 
  9.  
  10.  
  11. events { 
  12.     use epoll; 
  13.     worker_connections  1024; 
  14.  
  15.  
  16. http { 
  17.     include       mime.types; 
  18.     default_type  application/octet-stream; 
  19.  
  20.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 
  21.                       '$status $body_bytes_sent "$http_referer" ' 
  22.                       '"$http_user_agent" "$http_x_forwarded_for"'; 
  23.  
  24.     access_log  logs/access.log  main; 
  25.  
  26.     sendfile        on; 
  27.     #tcp_nopush     on; 
  28.  
  29.     #keepalive_timeout  0; 
  30.     keepalive_timeout  65; 
  31.  
  32.     gzip  on; 
  33.     gzip_min_length 1k; 
  34.     gzip_buffers    6   16k; 
  35.     gzip_http_version   1.1; 
  36.     gzip_comp_level 2; 
  37.     gzip_types  text/plain  application/x-javascript    text/css application/xml; 
  38.     gzip_vary   on; 
  39. #   location / { 
  40. #            root   html; 
  41. #            index  index.html index.htm; 
  42. #        } 
  43.         error_page  404              /404.html; 
  44.  
  45.     upstream www.test.com { 
  46.             server  192.168.11.37:80; 
  47.             server  192.168.11.38:80; 
  48.             } 
  49.  
  50.     server 
  51.     { 
  52.         listen  80; 
  53.         server_name www.test.com 192.168.11.208; 
  54.         index   index.htm  index.html; 
  55.         #root /web/wwwroot; 
  56.  
  57.     location / { 
  58.         proxy_pass http://www.test.com; 
  59.         proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header; 
  60.         proxy_set_header   Host             $host; 
  61.         proxy_set_header   X-Real-IP        $remote_addr; 
  62.         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 
  63.         include proxy.conf; 
  64.       } 
  65.     log_format  blog_test_com  '$remote_addr - $remote_user [$time_local] $request ' 
  66.                                 '"$status" $body_bytes_sent "$http_referer" ' 
  67.                                 '"$http_user_agent" "$http_x_forwarded_for"'; 
  68.               access_log logs/blog_test_com; 
  69.      } 
  70.     } 

proxy. conf 설정
   
   
   
   
  1. [root@localhost conf]# cat proxy.conf  
  2. proxy_redirect  off; 
  3. proxy_set_header    Host    $host; 
  4. proxy_set_header    X-Real-IP $remote_addr; 
  5. proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for; 
  6. client_body_buffer_size 128k; 
  7. proxy_connect_timeout 90; 
  8. proxy_send_timeout 90; 
  9. proxy_read_timeout 90; 
  10. proxy_buffer_size   4k; 
  11. proxy_buffers 6 32k; 
  12. proxy_busy_buffers_size 64k; 
  13. proxy_temp_file_write_size 64k; 

좋은 웹페이지 즐겨찾기