In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how Nginx reverse proxy learning is, the quality of the article content is high, so Xiaobian shares it with you as a reference, I hope you have a certain understanding of related knowledge after reading this article.
1. Reverse proxy preparation 1. Install Tomcat in Linux system
Extract tomcat to/usr/src. Jdk environment is required for startup. No jdk environment installed, I centos7 comes with jdk1.8.
2. start Tomcat
Enter tomcat bin directory, there is a startup.sh file.
./ startup.sh Start tomcat server
3. Open access ports
View currently open port numbers
firewall-cmd --list-all
Set open port numbers
firewall-cmd --add-port=80/tcp --permanentfirewall-cmd --add-port=8080/tcp --permanent
Restart firewall
firewall-cmd --reload 4. Test access tomcat
http://192.168.1.173:8080/
Since then, the preparatory work has been completed!
II. Reverse proxy case (I) 1. Realize the effect
Open the browser, enter www.123.com in the browser address bar, jump to the tomcat page of linux system
2. specific configuration
Step 1: Add to the local/etc/hosts file
Step 2: Configure the request forwarding in nginx (reverse proxy configuration)
cd /usr/local/nginx/conf
vim nginx.conf
Add something to modify
3. test
Visit www.123.com
Access tomcat by accessing nginx ip, success!!!
II. Reverse proxy case (II) to achieve results
Use nginx reverse proxy to jump to services on different ports according to the access path. The nginx listening port is 9001.
Visit 192.168.1.173/edu/ to jump directly to 192.168.1.173:8080
Visit 192.168.1.173:9001/vod/ to jump directly to 192.168.1.173:8081
1. preparations
(1) Prepare two tomcat servers, one port 8080 and one port 8081
(2) Create two folders, put them into tomcat compressed package, extract them, and then modify the server.xml file in conf of tomcat to change the port to 8081.
(3) Create edu and vod folders under webapps file respectively, and create a.html test page in the folder to display port number.
2. specific configuration
(1) Find the nginx configuration file and configure the reverse proxy.
(2) Port number 9001 8080 8081 open to external access
location instruction
This directive is used to match URLs
The syntax is as follows:
location [ = | ~ | ~* | ^~] uri {}
1.=: Before uri without regular expression, request string and uri are strictly matched. If they match,
If successful, stop searching downwards and process the request immediately.
2,~: Used to indicate that uri contains regular expressions and is case-sensitive.
3.~*: Used to indicate that uri contains regular expressions and is case-insensitive.
4.^~: Before using uri without regular expression, Nginx server is required to find the identifier uri and request word.
After the location with the highest string matching degree, immediately use this location to process the request instead of using location
The regular uri in the block matches the request string.
Note: If uri contains a regular expression, it must have a ~ or ~ identifier. *
final test
About Nginx reverse proxy learning is how to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.