手机版
你好,游客 登录 注册
背景:
阅读新闻

Ubuntu下配置Nginx+Keepalived做HA

[日期:2012-10-22] 来源:Linux社区  作者:penginpha [字体:大 中 小]

环境:Ubuntu 9.04、nginx-0.8.39、keepalived(在线安装)

目标:
ip1:192.168.0.116
ip2:192.168.0.117
vip:192.168.0.200

安装nginx
$tar -zxvf nginx-0.8.39
$cd nginx-0.8.39
$sudo ./configure
$make
$sudo make install

安装keepalived
$sudo apt-get install keepalived
//以下略过

配置nginx
$sudo vim nginx.conf //打开修改如

  1. #user  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  info; 
  7.  
  8. #pid        logs/nginx.pid; 
  9.  
  10. events { 
  11.     worker_connections  1024; 
  12. } 
  13.  
  14. http { 
  15.     include       mime.types; 
  16.     default_type  application/octet-stream; 
  17.  
  18.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 
  19.                       '$status $body_bytes_sent "$http_referer" ' 
  20.                       '"$http_user_agent" "$http_x_forwarded_for"'; 
  21.  
  22.     access_log  logs/access.log  main; 
  23.     sendfile        on; 
  24.     #tcp_nopush     on; 
  25.     keepalive_timeout  65; 
  26.     #gzip  on; 
  27.  
  28.     upstream 192.168.0.200 { #vip 
  29.         server 192.168.237.1:8088;   
  30.         server 192.168.237.128:8088; 
  31.         server 192.168.237.129:8088; 
  32.     } 
  33.  
  34.     server { 
  35.         listen       80; 
  36.         server_name  192.168.0.200; 
  37.  
  38.         #charset koi8-r; 
  39.         #access_log  logs/host.access.log  main; 
  40.  
  41.         location / { 
  42.             proxy_pass http://192.168.0.200; 
  43.         } 
  44.  
  45.         #error_page 404 /404.html; 
  46.  
  47.         # redirect server error pages to the static page /50x.html 
  48.         # 
  49.         error_page   500 502 503 504  /50x.html; 
  50.         location = /50x.html { 
  51.             root   html; 
  52.         } 
  53.  
  54.     location /nginx/status {     
  55.         stub_status on;     
  56.         access_log on;     
  57.         auth_basic "NginxStatus";     
  58.         #auth_basic_user_file conf/htpasswd;     
  59.         } 
  60.  
  61.     } 
  62. } 

PS:双机上配置相同。

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款