搭建Nginx负载均衡服务器(2)

# deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

#    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

#    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

#    ssl_session_timeout  5m;

#    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

#    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
  http
    {
        upstream {
            server  192.168.1.125:80 weight=3 max_fails=3 fail_timeout=20s;
            server  192.168.1.126:80 weight=1 max_fails=3 fail_timeout=20s;
            server  192.168.1.121:80 weight=5 max_fails=3 fail_timeout=20s;
            }

server
    {
        listen  80;
        server_name ;
        index   index.htm  index.html;
        #root /web/wwwroot;

location / {
        proxy_pass ;
        proxy_next_upstream http_500 http_502 http_503 error timeout invalid_header;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        include proxy.conf;
      }
    log_format  blog_linuxidc_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log logs/blog_linuxidc_com;
     }
   }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/89fa0859c5c06af621f0751b908c7553.html