In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the Nginx working mode and agent configuration example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
First, the working mode of Nginx. Single process mode
In single-process mode, there is only one process after Nginx starts, and this process is responsible for all the work of Nginx.
Advantages:
Because there is only one process in single-process mode, it is convenient to use tools such as gdb to debug.
Disadvantages:
The single-process mode does not support the smooth upgrade function of Nginx, and any signal processing may cause service interruption; and because it is a single process, after the process dies, the service cannot be restarted without external monitoring.
However, later Nginx has configured Master-Worker to work in the default mode, so there is no need to worry about the above problems.
[root@localhost ~] # ps aux | grep nginx | grep-v greproot 38395 0.0 264704 7192? Ss Dec15 0:00 nginx: master process / usr/local/nginx/sbin/nginxroot 3421689 0.0 0.0 294040 32680? S Dec24 0:00 nginx: worker process2.Master-Worker mode
After Nginx starts, there will be a Master process and at least one Worker process; the Master process is mainly responsible for processing system signals, loading configuration, managing Worker processes and other operations; while the Worker process is responsible for handling specific business logic, that is to say, to the outside, it is the Worker process that really provides services.
Advantages: high stability, as long as there is a Worker process alive, it can provide services, and after a Worker process dies, the Master process will immediately start a new Worker process to ensure that the number of Worker processes remains unchanged and reduce the probability of service interruption; at the same time, it can cooperate with Nginx's CPU affinity to make full use of the advantages of multicore CPU and improve performance.
3. Problem handling
Two days ago, when the blogger started Nginx, there was no problem, but not during access. At that time, by checking the port number, he found that the port existed. Later, he used ps to look at the process, and found that there was only one master process (the master process does not provide services). Finally, by looking at the error.log log, he found that:
The Worker process did not start because of a problem with the third-party module used.
There are two ways to deal with it: the first is to remove the third-party module from the configuration, and the second is to repair the third-party module.
II. Nginx proxy configuration
Here the blogger mainly introduces: the role of / in the Nginx configuration file, despite this small symbol, its role can be said to be related to whether the system can provide services normally.
The role of / in the Nginx configuration file is mainly reflected in the configuration of proxy_pass.
Preparatory work:
[root@PengYuYan ~] # yum-y install nginx [root@PengYuYan ~] # cat / usr/share/nginx/html/ZhangSan/index.html [root@PengYuYan ~] # mkdir / usr/share/nginx/html/PengYuYan [root@PengYuYan ~] # echo "This is 127.0.0.1 This is 80 PengYuYan" > / usr/share/nginx/html/PengYuYan/index.html [root@PengYuYan ~] # cat / www/html/index.html [root@PengYuYan ~] # mkdir / www/html/ ZhangSan [root@PengYuYan ~] # echo "This is 127.0.0.1 This is 8080 ZhangSan" > / www/html/ZhangSan/index.html [root@PengYuYan ~] # mkdir / www/html/PengYuYan [root@PengYuYan ~] # echo "This is 127.0.0.1 echo 8080 PengYuYan" > / www/html/PengYuYan/index.html
The following location, you do not need to reconfigure, because the above configuration corresponds to the following.
1. With / location / PengYuYan/ {proxy_pass http://127.0.0.1/8080/;}
Authentication: curl 127.0.0.1/PengYuYan/
Here, blogger, let's break it down:
The PengYuYan in our curl 127.0.0.1/PengYuYan/ is actually our location configuration on port 80, not the configuration on port 8080.
And we happen to add a / after the proxy_pass agent, which leads us to actually visit curl 127.0.0.1 8080 /
In other words, if we want to access the PengYuYan on port 8080 as configured above, we need curl 127.0.0.1/PengYuYan/PengYuYan/.
two。 Without / location / PengYuYan/ {proxy_pass http://127.0.0.1/8080/;}
Verify:
This is actually easy to understand, because we didn't add / after proxy_pass, so Nginx will automatically put the directory of location after proxy_pass.
Summary:
When our proxy_pass agent is followed by /, it does not add the directory configured by location
When our agent is not followed by /, Nginx will put the directory of location after proxy_pass.
1) add / (modify the original Server_80.conf file) with a directory
Location / PengYuYan/ {proxy_pass http://127.0.0.1/8080/;}
Verify:
2) do not add / if there is a directory
Location / ZhangSan/ {proxy_pass http://127.0.0.1/8080/ZhangSan;}
Verification: curl 127.0.0.1 curl ZhangSanmax, in our configuration, is actually visiting the curl 127.0.0.1:8080/ZhangSan/ZhangSan/
In fact, whether there is a directory or not, it is the same as summarized above by the blogger. It's mainly in Nginx.
The above is all the contents of the article "sample Analysis of Nginx working Mode and Agent configuration". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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: 221
*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.