【个人笔记】跟着官方文档学nginx——Basic Functionality基础功能

有点尴尬,官方文档看错地方了,真正的官方文档在https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/

基础功能分为两部分

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.html

本文将对nginx.conf 更细致的讲解

开始

nginx.conf 分为三个部分

Directives指令

普通指令如:

user             nobody;
error_log        logs/error.log notice; worker_processes 1;

Feature-Specific Configuration Files 特殊配置文件

推荐分割,保存在/etc/nginx/conf.d下,用include加载内容

ex:

include conf.d/http;
include conf.d/stream;
include conf.d/exchange-enhanced;

这里我看不懂,保存的啥,include取的啥

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.

猜你喜欢

转载自www.cnblogs.com/haon/p/10962329.html
今日推荐