nginx作为负载均衡(代理转发)时的配置文件样例nginx.conf

worker_processes  1;

events {
    use  epoll;
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream springboot_group {
        # If there is no specific strategy, round-robin
        #     would be the default strategy.
        # least_conn;
        # ip_hash;
        server 10.1.82.44:8080 weight=1 max_fails=2 fail_timeout=30s;
        #server 10.1.82.191:4080 weight=1 max_fails=2 fail_timeout=30s;
    }
    upstream tomcat_group {
        # If there is no specific strategy, round-robin
        #     would be the default strategy.
        # least_conn;
        # ip_hash;
        server 10.1.82.44:8081;
    }


    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://springboot_group;
        }
    }
    server {
        listen       81;
        server_name  localhost;

        location / {
            proxy_pass http://tomcat_group;
        }
    }

}
 

上一篇:当JPA遇上MySQL表名全大写+全小写+驼峰+匈牙利四风格


下一篇:java 类设置id生成策略