What language are nginx conf files?

前端 未结 3 1443
[愿得一人]
[愿得一人] 2021-01-31 01:15

I want to write some more complex conditions in my Nginx configuration files but I\'m not sure of the syntax and can\'t find docs describing what you can do beyond the basics in

3条回答
  •  感情败类
    2021-01-31 02:17

    The Nginx conf files are written in their own language or syntax. I've included some of the basics below. These are my own personal notes taken from Mastering Nginx

    Basic format

    the basic file is split into sections

    :
    
    
    { ; }

    Global parameters

    Not defined in the standard format described above, it has no {} surrounding global section. It is placed at the top of the config file

    Important global params

    user - user and group which the worker processes run. If group omitted it equals that to user used

    worker_processes - the number of worker processes started. They handle connections from clients. as a rule for CPU-bound loads this should equal number of processors and for I/O bound loads times this by 1.5 or 2

    error_log - locations of error_logs. can be overwritten within directives. A second param indicates the level of log debug (only available when debugging mod configured at compilation), info, notice, warn, error, crit, alert and emerg.

    pid - the file where the process ID of the main process is written, overwriting the compiled-in default.

    worker_connections - configures the maximum number of simultaneous connections that a worker process may have open. Especially important on reverse proxy servers – some additional tuning may be required at the operating-system level in order to reach this number of simultaneous connections.

    Using include files can be used anywhere in your configuration file

    include /opt/local/etc/nginx/mime.types;

    A wildcard may appear in the path to match multiple files: include /opt/local/etc/nginx/vhost/*.conf;

    A configuration file can be easily tested by calling NGINX as follows: nginx -t -c

    The Http section will be the most commonly used section.

提交回复
热议问题