In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you the Nginx environment, configuration and verification, hoping to give you some help in practical application. Load balancing involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
1. Environment:
Frontend Nginx CVM: hostname: server1
IP:172.25.80.1 compilation and installation of nginx1..12
Backend tomcat:
Server2--ip:172.25.80.2 hostname: server2
Server3--ip:172.25.80.3 hostname: server3
2. Ngginx configuration:
User nginx
Worker_processes 1
Events {
Use epoll
Worker_connections 4096
}
Http {
Include mime.types
Default_type application/octet-stream
Sendfile on
Tcp_nopush on
Tcp_nodelay on
Server_tokens off
Keepalive_timeout 65
Server_names_hash_max_size1024
Gzip on
Gzip_proxied any
Gzip_min_length 1000
Gzip_comp_level 4
Gzip_types text/plain text/cssapplication/json application/x-javascript text/xml application/xmlapplication/xml+rss text/javascript
Gzip_static on
Upstream tomcat {# defines a cluster of tomcat servers. The following is the IP and port of the included servers
Server 172.25.80.2:8080
Server 172.25.80.3:8080
}
Server {
Listen 80; # defines a listening port
Server_name server1.a.com; # defines the name of the virtual host
Location / {
Root html/www; # default root directory for virtual host
Home page file type recognized by index index.jspindex.html index.htm; #
}
Location ~ *\. (jsp | do) ${# is not sensitive to lowercase regular matching, and requests ending with .jsp and dp are evenly distributed to the backend server cluster tomcat.
Proxy_pass http://tomcat; # forwards matching requests to the tomcat cluster
}
Location ~ *\. (jpg | png | gif | jgeg | pdf) ${# matches the file types defined in parentheses without case sensitivity
Proxy_pass http://172.25.80.1:8080; # forwarded to this server
}
}
Include html/*.conf; # reads the .conf file in this directory
}
3, verify:
1) visit server1.a.com:
2) 2) visit node5.a.com/index.jsp
Note: because it is clearly defined in the nginx configuration file that requests that exactly match the end of .jsp will be forwarded to the tomcat cluster, the request will not be completed natively in nginx, but will be forwarded to the server cluster. In addition, since two servers are defined in the cluster, user requests are assigned in turn, that is, the function of load balancing is realized:
After reading the above about the Nginx environment, configuration and verification, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional technical engineer to answer, the technical engineer has more than ten years of experience in the industry.
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.