немного nginx: http balancer

Apr 20, 2015 13:31

worker_processes 10;

events {
      worker_connections  1024;
}

error_log  /var/log/nginx/error.log warn;

http {
    upstream backend {
        # round-robin - requests to the application servers are distributed in a round-robin fashion,
        # least-connected - next request is assigned to the server with the least number of active connections,
        # ip-hash - a hash-function is used to determine what server should be selected for the next request (based on the client’s IP address).
        least_conn;
        server 213.180.204.3  weight=3  max_fails=5 fail_timeout=2s;
        server 98.138.253.109  weight=3 max_fails=5 fail_timeout=2s;
        server 173.194.122.255  weight=3 max_fails=5 fail_timeout=2s;
}

server {
        listen 80;
        location / {
            proxy_pass http://backend;
            proxy_set_header   Host   $host;
            proxy_set_header   X-Real-IP  $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

#health_check; # interval=10 fails=3 passes=2;
        }
    }
}

ha, nginx

Previous post Next post
Up