nginx 之 LoadBalanceExample----upstream

Simple Load Balancing

http {
  upstream myproject {
    server 127.0.0.1:8000 weight=3;
    server 127.0.0.1:8001;
    server 127.0.0.1:8002;    
    server 127.0.0.1:8003;
  }
 
  server {
    listen 80;
    server_name www.domain.com;
    location / {
      proxy_pass http://myproject;
    }
  }
}

自己搭建的solr:

http {
upstream nginxproxy{
server 172.16.132.34:6602 max_fails=3 fail_timeout=5h;
server 172.16.132.159:6602 max_fails=3 fail_timeout=5h;
}
charset UTF-8;
include mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'[$status $body_bytes_sent $request_time] "$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;
access_log /var/log/nginx/default.access.log main;
error_log /var/log/nginx/default.error.log;

client_max_body_size 20M;
gzip on;
gzip_types application/json;
gzip_min_length 1024;
gzip_comp_level 2;
server{
listen 6602;
server_name 127.0.0.1;
proxy_connect_timeout 1;
proxy_send_timeout 300;
proxy_read_timeout 300;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://nginxproxy;
}
}

 
posted @ 2014-12-16 14:56  清晰-模块-组合-优化  阅读(894)  评论(0)    收藏  举报