nginx+tomcat负载均衡配置


worker_processes 1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  200;

   upstream zhaojun.com {
        ip_hash;                                    #解决session失效问题
        server 192.168.126.128:7070;   #服务器地址1
        server 192.168.126.128:9090;    #服务器地址2

    }

    server {
        listen       80;
        server_name  zhaojun.com;
location / {
            proxy_pass http://zhaojun.com;              #必须要加 http 开头,访问的就是此地址  
            proxy_set_header   Host             $host;  
            proxy_set_header   X-Real-IP        $remote_addr;  
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;  
}

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        }

    }

你可能感兴趣的:(nginx+tomcat负载均衡配置)