nginx 부하 균형 역방향 에이전트 설정 범례

nginx. conf 프로필 내용:
#          
worker_processes  1;
error_log    /usr/local/nginx/logs/nginx_error.log    crit;
pid          /usr/local/nginx/nginx.pid;
worker_rlimit_nofile   51200;
events {
     use epoll;
     worker_connections 51200;
}
http {
    include            mime.types;
    default_type    application/octet-stream;
    source_charset GB2312;
    server_names_hash_bucket_size 256;
    client_header_buffer_size 256k;
    large_client_header_buffers 4 256k;
    #size limits
    client_max_body_size            50m;
    client_body_buffer_size        256k;
    client_header_timeout    3m;
    client_body_timeout 3m;
    send_timeout            3m;
    sendfile on;
    tcp_nopush        on;
    keepalive_timeout 120; #    ,       502  
    tcp_nodelay on;

    #         ,weight    ,         .
    upstream webservers{
        server 192.168.12.2:80 weight=1;
        server 192.168.12.3:80 weight=2;
        keepalive 100;  #          
        #nginx       ,1,   2,weight 3,ip hash 4,fair(   ) 5,url_hash (   )
        #ip_hash        ip hash    ,             ,    session  
        ip_hash;
    }
    server {
        listen                80;
        server_name  192.168.12.1;
        charset GB2312;
        location / { 
        #  proxy_pass        fastcgi_pass
        proxy_pass         
        proxy_redirect off ;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 50m;
        client_body_buffer_size 256k;
        proxy_connect_timeout 30;
        proxy_send_timeout 30;
        proxy_read_timeout 60;
        proxy_buffer_size 256k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
        proxy_temp_file_write_size 256k;
        proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
        proxy_max_temp_file_size 128m; 
        }
    }
}

좋은 웹페이지 즐겨찾기