3. Nginx reverse proxy

First, configure the reverse proxy of Nginx

  1. Configure two Tomcat servers

    • Configure the ports of the two Tomcats to be 8087 and 8088

    • Ensure that the three ports of the two Tomcat servers are inconsistent before they can be started.

    • Start 8087 port to open Tomcat7, start 8088 port to open Tomcat8

  2. Configure Nginx reverse proxy server

    • Modify the configuration file

    • Notes on modifying the configuration file

      • Define the server in upstream tomcat7 to point to the server address pointed to by the reverse proxy. Don't forget the semicolon.

      • Define the proxy_pass of the location as http://tomcat7 , which corresponds to the upstream name.

upstream manager{
	server 192.168.31.159:8087;
   }
   server {
        listen       80;
        server_name  manager.dhc.com;

        location / {
            proxy_pass   http://manager;
            index  index.html index.htm;
        }
    }
    
    upstream portal{
	server 192.168.31.159:8088;
   }
    server {
        listen       80;
        server_name  portal.dhc.com;

        location / {
            proxy_pass   http://portal;
            index  index.html index.htm;
        }
    }

3. Restart and load the configuration file, and test whether it is successful

Requirements : Configure Nginx load balancing

1. Modification of the configuration file, other requirements are the same as the previous one

upstream portal{
	server 192.168.31.159:8087 weight=2;
	server 192.168.31.159:8088;
   }
    server {
        listen       80;
        server_name  portal.dhc.com;

        location / {
            proxy_pass   http://portal;
            index  index.html index.htm;
        }
    }

· You can configure the weight weight=2 in the upstream (polling)

...
...
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325344281&siteId=291194637