1. Reverse proxy preparation1. Install Tomcat in Linux systemUnzip tomcat to /usr/src. The jdk environment is required to start. If you don't have a jdk environment, install it. My centos7 comes with jdk1.8. 2. Start tomcatEnter the bin directory of tomcat, there is a startup.sh file. ./startup.sh starts the tomcat server 3. Ports open to external accessView currently open port numbers firewall-cmd --list-all Set the open port number firewall-cmd --add-port=80/tcp --permanent firewall-cmd --add-port=8080/tcp --permanent Restart the firewall firewall-cmd --reload 4. Test access to tomcathttp://192.168.1.173:8080/ The preliminary preparations are now complete!! 2. Reverse proxy case (I)1. Achieve resultsOpen the browser, enter www.123.com in the browser address bar, and jump to the Linux system tomcat page 2. Specific configurationStep 1: Add to the local /etc/hosts file The second step is to configure request forwarding in nginx (reverse proxy configuration)
Modify and add some content 3. TestingVisit www.123.com Access tomcat by accessing nginx's ip, success! ! ! ! 2. Reverse proxy case (II)Achieve resultsUse nginx reverse proxy to jump to services on different ports according to the access path. The nginx listening port is 9001.
1. Preparation(1) Prepare two tomcat servers, one with port 8080 and one with port 8081 (2) Create two folders, put the compressed packages of Tomcat in each folder, decompress them, and then modify the server.xml file in the conf file of one of the Tomcat files and change the port to 8081. (3) Create edu and vod folders under the webapps file, and create an a.html test page in the folder to display the port number. 2. Specific configuration(1) Find the nginx configuration file and configure the reverse proxy (2) Open ports for external access: 9001 8080 8081 location directive descriptionThis directive is used to match URLs The syntax is as follows: location [ = | ~ | ~* | ^~] uri { } 1. =: used before a URI that does not contain a regular expression, requiring the request string to strictly match the URI. If they match If successful, stop searching further and process the request immediately. 2. ~: Used to indicate that the URI contains a regular expression and is case-sensitive. 3. ~*: used to indicate that the URI contains a regular expression and is case insensitive. 4. ^~: used before the URI without regular expression, requiring the Nginx server to find the identifier URI and the request string After the location with the highest string matching degree is found, the request is processed immediately using this location instead of the location The regular uri in the block is matched against the request string. Note: If the uri contains a regular expression, the ~ or ~ sign must be present . * Final TestSummarizeThis is the end of this article about Nginx reverse proxy learning. For more relevant Nginx reverse proxy content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief discussion on the difference between MYSQL primary key constraint and unique constraint
>>: How to set the select to be read-only and not editable and the select value to be passable
This article records the detailed process of down...
# contains a location information. The default anc...
Preface Anyone who has learned JavaScript must be...
1. Concurrency Concurrency is the most important ...
The garbled code problem is as follows: The reaso...
background As the number of application systems c...
Today I used a virtual machine to do an experimen...
REPLACE Syntax REPLACE(String,from_str,to_str) Th...
translate(-50%,-50%) attributes: Move it up and l...
When I was writing the login page today, I needed...
Introduction Memcached is a distributed caching s...
1. Configuration By default, the first two are no...
Table of contents Write docker-compose.yml Run do...
Here are some points to note when registering Tom...
Anti-shake: Prevent repeated clicks from triggeri...