Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the structure of the nginx.conf configuration file

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge of what the structure of the nginx.conf configuration file is. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

The structure of the core profile

Nginx.conf is mainly composed of block configuration items such as events, http, server, location, upstream and some row configuration items.

# # events, http, server, location, upstream, etc. in the code block are all block configuration items # which specify which users to use. In the case of nobody, the number of # user nobody; # # Nginx worker processes directly affects performance. # each worker process is a single-threaded process, and they call each module to achieve a variety of functions. If there are no blocking calls in these modules, you should configure as many processes as there are CPU kernels, whereas blocking calls may occur, so you need to configure slightly more worker processes. Worker_processes 1; # # the default location of error logs is configured when we install nginx on linux, or you can modify it below. # syntax: error_log / path/file level;# default: error_log / log/error.log error;# when the value of path/file is / dev/null, no logs will be output, which is the only way to close error logs. The value range of # leve is debug, info, notice, warn, error, crit, alert, emerg from left to right. # when the level of level is error, logs at error, crit, alert and emerg levels will be output. Greater than or equal to this level will be output, and less than this level will not be output. # if the log level is set to debug, all logs will be output, which will be a large amount of data. You need to make sure that the disk on which / path/file resides has enough disk space in advance. If the level is set to debug, you must add the-- with-debug configuration item when you configure. # error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info; events {worker_connections 1024;} http {/ / introduces the settings of mime.types files, mainly by increasing the readability of include mime.types; default_type application/octet-stream; sendfile on / / set how long a tcp connection can stay alive keepalive_timeout 65; server {/ / here we configure the nginx home page and error redirect page. We configure the localhost:80 port here, and you can also define listen 80; server_name localhost as needed. / / access.log logs all user requests # access_log logs/host.access.log main; / / redirected nginx home page. The home page file is located in index.html location / {root html; index index.html under the html folder of the root directory. } / / error page, if there is an error, it will jump. / 50x.html error_page 500502 503504 / 50x.hml under the html folder of the root directory; location = / 50x.html {root html;}} / / the load balancing policy is configured here in the upstream block. Here is an example of polling: upstream bakend {server 192.168.1.10 weight=1; server 192.168.1.11 weight=2 } # introduce other conf include imooc.conf;} # imooc.conf server {listen 81; server_name localhost; / / jump nginx home page, the home page file is in the index.html location / {root html; index imooc123.html;}} nginx process model under the html folder of the root directory

Contains master processes (used to listen for commands and requests) and worker processes (used to handle asynchronous non-blocking mode: if the current client is blocked, it will continue to process requests from other client). Multiple worker can be enabled by configuration, each worker can handle hundreds of thousands or even millions of concurrency (depending on machine performance), but the default number of connections per worker is 1024.

These are all the contents of the article "what is the structure of the nginx.conf configuration file?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to 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: 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report