有點尷尬,官方文檔看錯地方了,真正的官方文檔在https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/html
基礎功能分爲兩部分nginx
Controlling NGINX Processes at Runtime——移步https://www.cnblogs.com/haon/p/10962160.html服務器
Creating NGINX Plus and NGINX Configuration Files——移步https://www.cnblogs.com/haon/p/10961838.htmlapp
本文將對nginx.conf 更細緻的講解tcp
開始
nginx.conf 分爲三個部分ide
Directives指令
普通指令如:ui
user nobody; error_log logs/error.log notice; worker_processes 1;
Feature-Specific Configuration Files 特殊配置文件
推薦分割,保存在/etc/nginx/conf.d下,用include加載內容spa
ex:code
include conf.d/http; include conf.d/stream; include conf.d/exchange-enhanced;
這裏我看不懂,保存的啥,include取的啥server
Contexts 內容主體
根據通訊種類不一樣分爲
針對一種通訊方式能夠有多個server指令塊(虛擬服務器),通訊方式決定server內的可用指令
user nobody; # a directive in the 'main' context events { # configuration of connection processing } http { # Configuration specific to HTTP and affecting all virtual servers server { # configuration of HTTP virtual server 1 location /one { # configuration for processing URIs starting with '/one' } location /two { # configuration for processing URIs starting with '/two' } } server { # configuration of HTTP virtual server 2 } } stream { # Configuration specific to TCP/UDP and affecting all virtual servers server { # configuration of TCP virtual server 1 } }
這裏還講了嵌套context的狀況,沒看懂,先保留
Inheritance
In general, a child context – one contained within another context (its parent) – inherits the settings of directives included at the parent level. Some directives can appear in multiple contexts, in which case you can override the setting inherited from the parent by including the directive in the child context. For an example, see the proxy_set_header
directive.