Linux (CENTOS7) Nginx simple load balancing configuration

The role of load balancing

  1, forwarding

    According to a certain algorithm [weight] polling, the client forwards the request to a different application server, a single server reduce stress and improve system concurrency.

  2, failure to remove

    By way of heartbeat, the application server determines whether the current operating normally, the server of the shoot down, automatically sends a request to another application server.

  3, add recovery

    As the server application detects a failure recovery, automatically added to the team process user requests.

 

LINUX (CENTOS7) NGINX installation Address: https://www.cnblogs.com/kawhileonardfans/p/10966581.html


After nginx ready, because I only have a server here, so I am here to prepare a server on top of two simple tomcat, as shown below

 

  Find nginx configuration files, configuration files I have here in / usr / local / nginx / conf below, the increase in http:

upstream tomcatserver1 {  
    server 139.199.203.169:8081 weight=3;  
    server 139.199.203.169:8082;  
} 

  Then modify the server as follows:

server {  
        listen       80;  
        server_name  8080.max.com;  
        #charset koi8-r;  
        #access_log  logs/host.access.log  main;  
        location / {  
            proxy_pass   http://tomcatserver1;  
                index  index.html index.htm;  
        }  
}

  The results after revision as follows:

Restart nginx

  After the restart, and then use the address: http://139.199.203.169/test/index.html can look after the effect of configuration, and constantly refresh the page you can see sometimes tomcat1, sometimes tomcat2.

Guess you like

Origin www.cnblogs.com/kawhileonardfans/p/10966779.html