1. Core functions

1.1. error_log

Reference: https://www.yuque.com/heyingsheng/czqomy/snan44#Aiptd

1.2. include

  • Directive

    1. Syntax: include file|mask ;
    2. Default: Close
    3. Context: any
  • Instroduction

Includes another file, or files matching the specified mask, into configuration. Included files should consist of syntactically correct directives and blocks.

1.3. pid

  • Directive

    1. Syntax: pid file ;
    2. Default: pid logs/nginx.pid ;
    3. Context: main
  • Instroduction

Specify a file to save master process pid.

1.4. user

  • Directive

    1. Syntax: user username [group] ;
    2. Default: user nobody nobody ;
    3. Context: main
  • Instroduction

Defines user and group that owner of worker processes.If group is omitted,a group whose name equals that of user is used.

1.5. worker_proess

  • Directive

    1. Syntax: worker_process number|auto ;
    2. Default: worker_process 1 ;
    3. Context: main
  • Instroduction

Set number of worker process.The better number is not large than CPU cores(# lscpu).The value equal to CPU cores when sets auto.

1.6. worker_priority

  • Directive

    1. Syntax: worker_priority number ;
    2. Default: worker_priority 0;
    3. Context: main
  • Instroduction

Sets CPU task scheduling priority for worker process(like nice command),the value from -20 ~ 20.The negative means high priority.

1.7. worker_cpu_affinity

  • Directive

    1. Syntax: worker_cpu_affinity cpumask ... | auto ;
    2. Default: Close
    3. Context: main
  • Instroduction

Binds worker process to the sets of CPU cores,usually auto is best choice.For example:

  1. worker_process 4 ;
  2. worker_cpu_affinity 0001 0010 0100 1000 ;

1.8. worker_rlimit_nofile

  • Directive

    1. Syntax: worker_rlimit_nofile number ;
    2. Default: Close
    3. Context: main
  • Instroduction

Changes the limit on the maximum number of open files for worker processes.Used to increase the limit without restaring the mian process.

1.9. event

  • Directive

    1. Syntax: event {...}
    2. Default:
    3. Context: main
  • Instroduction

Provides the configuration file context in which the directives that affect connection processing are specified.

1.10. use

  • Directive

    1. Syntax: use methon ;
    2. Default: Close
    3. Context: events
  • Instroduction

Specifies the connection processing method to use. There is normally no need to specify it explicitly, because nginx will by default use the most efficient method. However we set use epoll method.


2. http_core_module

2.1. limit_except

  • Directive

    1. Syntax: limit_except method ... {} ;
    2. Default: Close ;
    3. Context: location
  • Instroduction

Limits allowed HTTP methods inside a location. The method parameter can be one of the following: GET, HEAD, POST, PUT, DELETE, MKCOL, COPY, MOVE, OPTIONS, PROPFIND, PROPPATCH, LOCK, UNLOCK, or PATCH. Allowing the GET method makes the HEAD method also allowed.

2.2. merge_slashes

  • Directive

    1. Syntax: merge_slashes on | off ;
    2. Default: merge_slashes on ;
    3. Context: http,server
  • Instroduction

Enables or disables compression of two or more adjacent slashes(/) in a URI into a single slash.Compress more than one / to one / .
Turning the compression off can become necessary if a URI contains base64-encoded names, since base64 uses the “/” character internally.
If the directive is specified on the server level, its value is only used if a server is a default one. The value specified also applies to all virtual servers listening on the same address and port.

2.3. server_tokens

  • Directive

    1. Syntax: server_tokens on|off|build|string ;
    2. Default: server_tokens on ;
    3. Context: http,server,location
  • Instroduction

Enable or disable nginx version on error page and response header.
Parameters:

  • on : enable nginx version
  • off: only show server type like nignx,disable nginx version
  • build: show server name when build name when ./configure.
  • string: commercial subscription configuration.