首页 > 其他 > 详细

nginx负载均衡之upstream

时间:2015-10-22 14:22:45      阅读:223      评论:0      收藏:0      [点我收藏+]
  • 前言

 nginx作为负载均衡器的简单配置,只为干货!不做说明。

  • 参考资料

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

  • 配置文件

[root@mysql conf]# cat /application/nginx/conf/nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
upstream backend {
    server 192.168.1.198:80       max_fails=3 fail_timeout=30s;
    server 192.168.1.197:80       max_fails=3 fail_timeout=30s;
}
    server {
        listen       80;
        server_name  chborg.com;
        index  index.html index.htm;
        location / {
        proxy_pass http://backend;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
  • 语法格式

Syntax: upstream name {......}
Default: --
Context: http
  • 例子

upstream backend {
    server backend1.example.com       weight=5;
    server backend2.example.com:8080;
    server unix:/tmp/backend3;

    server backup1.example.com:8080   backup;
    server backup2.example.com:8080   backup;
}

server {
    location / {
        proxy_pass http://backend;
    }
}


本文出自 “挨刀客” 博客,请务必保留此出处http://chboy.blog.51cto.com/9959876/1705156

nginx负载均衡之upstream

原文:http://chboy.blog.51cto.com/9959876/1705156

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!