Lightweight server nginx: specific configuration of reverse proxy

Series Article Directory

For example: the use of pandas in Chapter 1 Introduction to Python Machine Learning


a reverse proxy

1. Forward proxy

If we are in China, if we want to visit Google, we cannot access it. We need to use a forward proxy server, first pass the information to the proxy server, and the location of the proxy server can access Google, so that the proxy can go to Google to get it and Return the data and send the information to your own terminal.
insert image description here

2. Reverse proxy

If a website has a large number of users, we need to choose a reverse proxy server. The requests of these users are evenly distributed to subsequent application servers to prevent the occurrence of high load on one server and nothing to do on the other server.
insert image description here

The actual deployment of the second reverse proxy

Purpose, by configuring nginx, users send requests for tomcat projects through domain names

1. Configure tomcat

In this sever.xml, add one to the three port numbers

insert image description here
Xftp into this directory and delete all the contents inside

/usr/tomcat2/apache-tomcat-7.0.68/webapps/ROOT

Add a static resource and add this content to it.
insert image description here
Tomcat2 also operates in the same way
and puts in some resources that can actually run

execute tomcat

/usr/tomcat/apache-tomcat-7.0.68/webapps/ROOT
[root@localhost bin]# cd /usr/tomcat/apache-tomcat-7.0.68/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /usr/tomcat/apache-tomcat-7.0.68
Using CATALINA_HOME:   /usr/tomcat/apache-tomcat-7.0.68
Using CATALINA_TMPDIR: /usr/tomcat/apache-tomcat-7.0.68/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_261/
Using CLASSPATH:       /usr/tomcat/apache-tomcat-7.0.68/bin/bootstrap.jar:/usr/tomcat/apache-tomcat-7.0.68/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# cd /usr/tomcat2/apache-tomcat-7.0.68/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /usr/tomcat2/apache-tomcat-7.0.68
Using CATALINA_HOME:   /usr/tomcat2/apache-tomcat-7.0.68
Using CATALINA_TMPDIR: /usr/tomcat2/apache-tomcat-7.0.68/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_261/
Using CLASSPATH:       /usr/tomcat2/apache-tomcat-7.0.68/bin/bootstrap.jar:/usr/tomcat2/apache-tomcat-7.0.68/bin/tomcat-juli.jar
Tomcat started.

8081insert image description here
8080
insert image description here

2. Configure host, nginx

C:\Windows\System32\drivers\etc

Select this hosts file
and append at the end

192.168.80.121 www.xyt1.com
192.168.80.121 www.xyt2.com

Next, start configuring nginx

Configuration of reverse proxy

Append information at the end

upstream xyt1{
    
    
server 192.168.80.121:8080;
}
	
	server {
    
    
        listen       80;
        server_name  http://xyt1;
        location / {
    
    
            proxy_pass  http://xyt1;
            index  index.html;
        }
       
    }
	
upstream xyt2{
    
    
server 192.168.80.121:8081;
}
	
	server {
    
    
        listen       80;
        server_name  http://xyt2;
        location / {
    
    
            proxy_pass  http://xyt2;
            index  index.html;
        }
       
    }
    

Three result display

insert image description here
insert image description here

Four summary

Tomcat startup command

[root@localhost sbin]# cd /usr/tomcat2/apache-tomcat-7.0.68/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /usr/tomcat2/apache-tomcat-7.0.68
Using CATALINA_HOME:   /usr/tomcat2/apache-tomcat-7.0.68
Using CATALINA_TMPDIR: /usr/tomcat2/apache-tomcat-7.0.68/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_261/
Using CLASSPATH:       /usr/tomcat2/apache-tomcat-7.0.68/bin/bootstrap.jar:/usr/tomcat2/apache-tomcat-7.0.68/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# cd /usr/tomcat/apache-tomcat-7.0.68/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE:   /usr/tomcat/apache-tomcat-7.0.68
Using CATALINA_HOME:   /usr/tomcat/apache-tomcat-7.0.68
Using CATALINA_TMPDIR: /usr/tomcat/apache-tomcat-7.0.68/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_261/
Using CLASSPATH:       /usr/tomcat/apache-tomcat-7.0.68/bin/bootstrap.jar:/usr/tomcat/apache-tomcat-7.0.68/bin/tomcat-juli.jar
Tomcat started.

closure

./shutdown,sh

start nginx

./nginx

nginx restart

./nginx -s reload

Guess you like

Origin blog.csdn.net/CNMBZY/article/details/130348903