NGINX笔记

[键入公司名称]

Nginx笔记

[键入文档副标题]

Alex Zhao

[选取日期]

[在此处键入文档摘要。摘要通常为文档内容的简短概括。在此处键入文档摘要。摘要通常为文档内容的简短概括。]

  1. 简介
    1. Nginx基本命令和配置
      1. Nginx基本命令

Nginx提供了使用Nginx的基本命令,如下表所示:

命令

参数

说明

nginx –s signal

stop—快速停止

quit—优雅停止

reload—重新加载配置文件

reopen—重新打开日志文件

nginx进程发送信号

kill –s signal pid

同上

使用unix例如kill同样可以将一个信号传递给nginx,使用这种方法时需要使用nginx的进程id作为参数。Nginx的进程id默认保存在/usr/local/nginx/logs /var/run目录下的nginx.pid文件内

      1. Nginx配置文件结构

Nginx由模块(module)组成,这些模块由配置文件中的指令(directives)进行控制。

Nginx指令分为:

  1. 简单指令;
  2. 块指令。

简单指令格式如下:

         指令名称 指令参数;

块指令与简单指令类似,只不过将简单指令末尾的分号换成了由其他指令组成的集合。块指令的格式如下:

         指令名称 指令参数 {指令集合}

如果块指令内又有块指令,那么称其为context。

Context之外的指令为main指令。

Events和http指令在main context中,server在http中,location在server中。

         一个nginx配置文件的典型结构如下所示:

         Main指令

         http {

                   server {

         location {

                   指令

                   …

}

}

}

Nginx配置文件使用#作为注释符号。

      1. 为静态内容系统服务

Web服务器的一个重要工作就是对外提供静态文件服务。Nginx通过location块实现此功能。根据前文所说的“Events和http指令在main context中,server在http中,location在server中”,location块如下所示:

http {

server {

             location / {

                 root /data/www;

             }

             location /images/ {

                 root /data;

             }

}

}

上述的location块指定了一个“/”前缀,nginx用请求中的URI地址与该参数比较,如果两者匹配,那么该URI被添加到root指令中的参数形成一个新的路径,这个路径就是请求的文件在本地文件系统中的路径。假设现在有一个请求,请求访问/images/hello.jpg,那么请求的文件在本地文件系统中的全路径时/data/images/hello.jpg。如果该文件不存在,则返回404 error。

一个URI能够匹配多个location时,匹配长度最多的location生效。

      1. 简单代理服务器

Nginx的一个常见的使用是作代理服务器(proxy server)。代理服务器的含义是,一个服务器将收到的请求传递给其他被代理服务器(proxied server),同时将从被代理服务器获取到的响应又发送给客户端。如下图所示:

如下所示是一个基本的代理服务器配置:

server {

    location / {

        proxy_pass http://localhost:8080/;

    }

    location ~ \.(gif|jpg|png)$ {

        root /data/images;

    }

}

Nginx支持标准的正则表达式作为参数进行URI匹配。使用正则表达式作为参数时需要以~为开头。~ \.(gif|jpg|png)$表示匹配以.gif、.jpg或.png结尾的URI。根据上述配置,.gif、.jpg或.png结尾的URI将匹配到root /data/images;指令;对非.gif、.jpg或.png结尾的URI将转发到被代理服务器http://localhost:8080/

如下所示是将请求代理到fastcgi协议的端口:

server {

    location / {

        fastcgi_pass  localhost:9000;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_param QUERY_STRING    $query_string;

    }

    location ~ \.(gif|jpg|png)$ {

        root /data/images;

    }

}

    1. Nginx管理

前面提到Nginx支持使用信号进行管理。以下是主进程(master process)支持的信号:

信号名称

说明

TERM, INT

fast shutdown

QUIT

graceful shutdown

HUP

changing configuration, keeping up with a changed time zone (only for FreeBSD and Linux), starting new worker processes with a new configuration, graceful shutdown of old worker processes

USR1

re-opening log files

USR2

upgrading an executable file

WINCH

graceful shutdown of worker processes

以下是工作进程(worker process)支持的信号:

信号名称

说明

TERM, INT

fast shutdown

QUIT

graceful shutdown

USR1

re-opening log files

WINCH

abnormal termination for debugging (requires debug_points to be enabled)

      1. 修改配置

可以使用以下命令查看Nginx的所有进程:

ps axw -o pid,ppid,user,%cpu,vsz,wchan,command | egrep '(nginx|PID)'

上述命令执行结果如下:

  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND

33126     1 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx

33127 33126 nobody   0.0  1380 kqread nginx: worker process (nginx)

33128 33126 nobody   0.0  1364 kqread nginx: worker process (nginx)

33129 33126 nobody   0.0  1364 kqread nginx: worker process (nginx)

如果HUP信号被发送给主进程,输出可能变为:

  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND

33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx

33129 33126 nobody   0.0  1380 kqread nginx: worker process is shutting down (nginx)

33134 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)

33135 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)

33136 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)

其中一个旧的工作进程(33129)正在关闭。一段时间后再次查询会看到该进程消失。

      1. 滚动日志文件

使用USR1信号可以滚动日志文件。具体过程略。

      1. 在线升级可执行文件

为了升级可执行文件,首先在文件系统中替换掉旧的可执行文件。然后使用USR2信号进行升级。旧的主进程重命名其pid文件,使得新的主进程得以使用pid文件启动。待新的主进程和工作进程成功启动后,旧的主进程和工作退出。

新进程启动:

  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND

33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx

33134 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)

33135 33126 nobody   0.0  1380 kqread nginx: worker process (nginx)

33136 33126 nobody   0.0  1368 kqread nginx: worker process (nginx)

36264 33126 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx

36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

旧进程渐渐退出:

  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND

33126     1 root     0.0  1164 pause  nginx: master process /usr/local/nginx/sbin/nginx

33135 33126 nobody   0.0  1380 kqread nginx: worker process is shutting down (nginx)

36264 33126 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx

36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

最终升级完毕:

  PID  PPID USER    %CPU   VSZ WCHAN  COMMAND

36264     1 root     0.0  1148 pause  nginx: master process /usr/local/nginx/sbin/nginx

36265 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36266 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

36267 36264 nobody   0.0  1364 kqread nginx: worker process (nginx)

    1. Nginx连接处理方法

针对Nginx与外部的连接,Nginx提供了多种处理连接的方法。如下表所示:

类型

说明

select

标准方式

poll

标准方式

kqueue

efficient method used on FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0, and macOS

epoll

efficient method used on Linux 2.6+

/dev/poll

efficient method used on Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+, and Tru64 UNIX 5.1A+

eventport

event ports, method used on Solaris 10+ (due to known issues, it is recommended using the /dev/poll method instead)

    1. 建立哈希

为了快速处理静态数据集合,例如sever名、映射指令的值、MIME类型、请求头字符串名称,Nginx使用了哈希表。具体过程略。

    1. 调试日志

使用Nginx调试日志需要在配置编译选项时带debug选项,如:./configure --with-debug。Debug文件由error_log指令设置,如:error_log /path/to/log debug;。为了验证nginx已经配置为支持debug,可以使用nginx –V命令验证。

预编译的linux包可以使用server nginx-debug start启动调试模式的nginx。

此外每个server可以使用error_log命令定义自己的日志文件。

      1. 调试选中的客户端

如果日志太多,可以只针对选中的客户端打印调试日志。命令如下:

error_log /path/to/log;

events {

    debug_connection 192.168.1.1;

    debug_connection 192.168.10.0/24;

}

      1. 将日志记录到内存

可以将日志记录到内存,这样在负载很重的情况下,也不会因调试降低太多性能。命令如下:

error_log memory:32m debug;

set $log = ngx_cycle->log

while $log->writer != ngx_log_memory_writer

    set $log = $log->next

end

set $buf = (ngx_log_memory_buf_t *) $log->wdata

dump binary memory debug_log.txt $buf->start $buf->end

    1. 将日志记录到syslog
    2. 配置文件度量单位

如下表所示:

单位后缀

意义

kK

kilobyte

mM

megabyte

gG

gigabyte

ms

millisecond

s

second

m

minute

h

hour

d

day

w

week

M

mouth30days

y

year356days

多个单位可以同时使用,例如1h30s。

有时时间的最低分辨率为秒。

    1. 命令行参数

Nginx支持以下命令行参数:

参数

意义

-? | -h

打印命令行参数帮助

-c file

指定可变的配置文件替代默认文件

-g directives

设置全局配置指令,例如:

nginx -g "pid /var/run/nginx.pid; worker_processes `sysctl -n hw.ncpu`;"

-p prefix

设置nginx路径前缀,例如保存服务器文件的目录(默认是/usr/local/nginx

-q

配置检测过程中平息非错误信息

-s signal

向主进程发送信号量

-t

测试配置文件

-T

-t一样,但是增加额外的配置文件转储到标准输出

-v

打印版本

-V

打印版本,编译器版本,配置参数

    1. Nginx如何处理请求
      1. 基于名字的虚拟服务器

Nginx首先决定那个服务器应该处理该请求。

Nginx用请求头中的“Host”域去和配置文件中的server块匹配。匹配到之后,就将该请求路由给该server处理。

      1. 如何阻止不带服务器名的请求

命令如下:

server {

    listen      80;

    server_name "";

    return      444;

}

从0.8.48之后,空字符串是默认服务器名,所以服务器名可以被省略。早期的版本,机器的主机名被用作默认服务器名。

      1. 混合式基于名字和基于IP地址的虚拟服务器

当一个server块中既监听了ip端口又指定了server_name时,首先匹配listen指令,然后匹配server_name 指令。例如:

server {

    listen      192.168.1.1:80;

    server_name example.org www.example.org;

    ...

}

server {

    listen      192.168.1.1:80 default_server;

    server_name example.net www.example.net;

    ...

}

server {

    listen      192.168.1.2:80;

    server_name example.com www.example.com;

    ...

}

如果匹配不到server_name,则使用默认server处理。Default_server是listen指令的属性。

      1. 一个简单的PHP站点的配置

配置如下:

server {

    listen      80;

    server_name example.org www.example.org;

    root        /data/www;

    location / {

        index   index.html index.php;

    }

    location ~* \.(gif|jpg|png)$ {

        expires 30d;

    }

    location ~ \.php$ {

        fastcgi_pass  localhost:9000;

        fastcgi_param SCRIPT_FILENAME

                      $document_root$fastcgi_script_name;

        include       fastcgi_params;

    }

}

该站点可以接收并处理类似的命令:

/index.php?page=1&something+else&user=john

    1. Nginx如何处理TCP/UDP链接

一个从客户端发来的TCP/UDP链接被以以下步骤(阶段)处理:

  1. Post-accept:收到链接后的第一个阶段。ngx_stream_realip_module模块会被调用;
  2. Pre-access:主要进行访问检查。ngx_stream_limit_conn_module模块会被调用;
  3. Access:在真实数据处理前的客户端访问限制。ngx_stream_access_module模块会被调用;
  4. SSL:TLS/SSL终端。ngx_stream_ssl_module模块会被调用;
  5. Preread:读取数据的初始化字节到preread buffer,以便允许如ngx_stream_ssl_preread_module之类的模块进行处理前的数据分析;
  6. Content:数据真实处理的强制性阶段,通常是被代理到upstream server,或者是返回给客户端的指定值;
  7. Log:最后阶段,在该阶段处理结果被记日志。ngx_stream_log_module模块会被调用。
  1. 模块参考

Nginx内置以下module:

    1. ngx_http_core_module
    2. ngx_http_access_module
    3. ngx_http_addition_module
    4. ngx_http_api_module
    5. ngx_http_auth_basic_module
    6. ngx_http_auth_jwt_module
    7. ngx_http_auth_request_module
    8. ngx_http_autoindex_module
    9. ngx_http_browser_module
    10. ngx_http_charset_module
    11. ngx_http_dav_module
    12. ngx_http_empty_gif_module
    13. ngx_http_f4f_module
    14. ngx_http_fastcgi_module
    15. ngx_http_flv_module
    16. ngx_http_geo_module
    17. ngx_http_geoip_module
    18. ngx_http_grpc_module
    19. ngx_http_gunzip_module
    20. ngx_http_gzip_module
    21. ngx_http_gzip_static_module
    22. ngx_http_headers_module
    23. ngx_http_hls_module
    24. ngx_http_image_filter_module
    25. ngx_http_index_module
    26. ngx_http_js_module
    27. ngx_http_keyval_module
    28. ngx_http_limit_conn_module
    29. ngx_http_limit_req_module
    30. ngx_http_log_module
    31. ngx_http_map_module
    32. ngx_http_memcached_module
    33. ngx_http_mirror_module
    34. ngx_http_mp4_module
    35. ngx_http_perl_module
    36. ngx_http_proxy_module
    37. ngx_http_random_index_module
    38. ngx_http_realip_module
    39. ngx_http_referer_module
    40. ngx_http_rewrite_module
    41. ngx_http_scgi_module
    42. ngx_http_secure_link_module
    43. ngx_http_session_log_module
    44. ngx_http_slice_module
    45. ngx_http_spdy_module
    46. ngx_http_split_clients_module
    47. ngx_http_ssi_module
    48. ngx_http_ssl_module
    49. ngx_http_status_module
    50. ngx_http_stub_status_module
    51. ngx_http_sub_module
    52. ngx_http_upstream_module
    53. ngx_http_upstream_conf_module
    54. ngx_http_upstream_hc_module
    55. ngx_http_userid_module
    56. ngx_http_uwsgi_module
    57. ngx_http_v2_module
    58. ngx_http_xslt_module
    59. ngx_mail_core_module
    60. ngx_mail_auth_http_module
    61. ngx_mail_proxy_module
    62. ngx_mail_ssl_module
    63. ngx_mail_imap_module
    64. ngx_mail_pop3_module
    65. ngx_mail_smtp_module
    66. ngx_stream_core_module
    67. ngx_stream_access_module
    68. ngx_stream_geo_module
    69. ngx_stream_geoip_module
    70. ngx_stream_js_module
    71. ngx_stream_keyval_module
    72. ngx_stream_limit_conn_module
    73. ngx_stream_log_module
    74. ngx_stream_map_module
    75. ngx_stream_proxy_module
    76. ngx_stream_realip_module
    77. ngx_stream_return_module
    78. ngx_stream_split_clients_module
    79. ngx_stream_ssl_module
    80. ngx_stream_ssl_preread_module
    81. ngx_stream_upstream_module
    82. ngx_stream_upstream_hc_module
    83. ngx_stream_zone_sync_module
    84. ngx_google_perftools_module

nginx内置module可以分为以下几类:

  1. ngx_http_前缀开头的,http相关module;
  2. gnx_mail_前缀开头的,mail相关module;
  3. gnx_stream_前缀开头的,stream相关module;
  4. ngx_google_前缀开头的,google相关module。
    1. 指令

序号

指令名

备注

absolute_redirect

accept_mutex

accept_mutex_delay

access_log (ngx_http_log_module)

access_log (ngx_stream_log_module)

add_after_body

add_before_body

add_header

add_trailer

addition_types

aio

aio_write

alias

allow (ngx_http_access_module)

allow (ngx_stream_access_module)

ancient_browser

ancient_browser_value

api

auth_basic

auth_basic_user_file

auth_delay

auth_http

auth_http_header

auth_http_pass_client_cert

auth_http_timeout

auth_jwt

auth_jwt_claim_set

auth_jwt_header_set

auth_jwt_key_file

auth_jwt_key_request

auth_jwt_leeway

auth_request

auth_request_set

autoindex

autoindex_exact_size

autoindex_format

autoindex_localtime

break

charset

charset_map

charset_types

chunked_transfer_encoding

client_body_buffer_size

client_body_in_file_only

client_body_in_single_buffer

client_body_temp_path

client_body_timeout

client_header_buffer_size

client_header_timeout

client_max_body_size

connection_pool_size

create_full_put_path

daemon

dav_access

dav_methods

debug_connection

debug_points

default_type

deny (ngx_http_access_module)

deny (ngx_stream_access_module)

directio

directio_alignment

disable_symlinks

empty_gif

env

error_log

error_page

etag

events

expires

f4f

f4f_buffer_size

fastcgi_bind

fastcgi_buffer_size

fastcgi_buffering

fastcgi_buffers

fastcgi_busy_buffers_size

fastcgi_cache

fastcgi_cache_background_update

fastcgi_cache_bypass

fastcgi_cache_key

fastcgi_cache_lock

fastcgi_cache_lock_age

fastcgi_cache_lock_timeout

fastcgi_cache_max_range_offset

fastcgi_cache_methods

fastcgi_cache_min_uses

fastcgi_cache_path

fastcgi_cache_purge

fastcgi_cache_revalidate

fastcgi_cache_use_stale

fastcgi_cache_valid

fastcgi_catch_stderr

fastcgi_connect_timeout

fastcgi_force_ranges

fastcgi_hide_header

fastcgi_ignore_client_abort

fastcgi_ignore_headers

fastcgi_index

fastcgi_intercept_errors

fastcgi_keep_conn

fastcgi_limit_rate

fastcgi_max_temp_file_size

fastcgi_next_upstream

fastcgi_next_upstream_timeout

fastcgi_next_upstream_tries

fastcgi_no_cache

fastcgi_param

fastcgi_pass

fastcgi_pass_header

fastcgi_pass_request_body

fastcgi_pass_request_headers

fastcgi_read_timeout

fastcgi_request_buffering

fastcgi_send_lowat

fastcgi_send_timeout

fastcgi_socket_keepalive

fastcgi_split_path_info

fastcgi_store

fastcgi_store_access

fastcgi_temp_file_write_size

fastcgi_temp_path

flv

geo (ngx_http_geo_module)

geo (ngx_stream_geo_module)

geoip_city (ngx_http_geoip_module)

geoip_city (ngx_stream_geoip_module)

geoip_country (ngx_http_geoip_module)

geoip_country (ngx_stream_geoip_module)

geoip_org (ngx_http_geoip_module)

geoip_org (ngx_stream_geoip_module)

geoip_proxy

geoip_proxy_recursive

google_perftools_profiles

grpc_bind

grpc_buffer_size

grpc_connect_timeout

grpc_hide_header

grpc_ignore_headers

grpc_intercept_errors

grpc_next_upstream

grpc_next_upstream_timeout

grpc_next_upstream_tries

grpc_pass

grpc_pass_header

grpc_read_timeout

grpc_send_timeout

grpc_set_header

grpc_socket_keepalive

grpc_ssl_certificate

grpc_ssl_certificate_key

grpc_ssl_ciphers

grpc_ssl_crl

grpc_ssl_name

grpc_ssl_password_file

grpc_ssl_protocols

grpc_ssl_server_name

grpc_ssl_session_reuse

grpc_ssl_trusted_certificate

grpc_ssl_verify

grpc_ssl_verify_depth

gunzip

gunzip_buffers

gzip

gzip_buffers

gzip_comp_level

gzip_disable

gzip_http_version

gzip_min_length

gzip_proxied

gzip_static

gzip_types

gzip_vary

hash (ngx_http_upstream_module)

hash (ngx_stream_upstream_module)

health_check (ngx_http_upstream_hc_module)

health_check (ngx_stream_upstream_hc_module)

health_check_timeout

hls

hls_buffers

hls_forward_args

hls_fragment

hls_mp4_buffer_size

hls_mp4_max_buffer_size

http

http2_body_preread_size

http2_chunk_size

http2_idle_timeout

http2_max_concurrent_pushes

http2_max_concurrent_streams

http2_max_field_size

http2_max_header_size

http2_max_requests

http2_push

http2_push_preload

http2_recv_buffer_size

http2_recv_timeout

if

if_modified_since

ignore_invalid_headers

image_filter

image_filter_buffer

image_filter_interlace

image_filter_jpeg_quality

image_filter_sharpen

image_filter_transparency

image_filter_webp_quality

imap_auth

imap_capabilities

imap_client_buffer

include

index

internal

ip_hash

js_access

js_content

js_filter

js_import (ngx_http_js_module)

js_import (ngx_stream_js_module)

js_include (ngx_http_js_module)

js_include (ngx_stream_js_module)

js_path (ngx_http_js_module)

js_path (ngx_stream_js_module)

js_preread

js_set (ngx_http_js_module)

js_set (ngx_stream_js_module)

keepalive

keepalive_disable

keepalive_requests (ngx_http_core_module)

keepalive_requests (ngx_http_upstream_module)

keepalive_timeout (ngx_http_core_module)

keepalive_timeout (ngx_http_upstream_module)

keyval (ngx_http_keyval_module)

keyval (ngx_stream_keyval_module)

keyval_zone (ngx_http_keyval_module)

keyval_zone (ngx_stream_keyval_module)

large_client_header_buffers

least_conn (ngx_http_upstream_module)

least_conn (ngx_stream_upstream_module)

least_time (ngx_http_upstream_module)

least_time (ngx_stream_upstream_module)

limit_conn (ngx_http_limit_conn_module)

limit_conn (ngx_stream_limit_conn_module)

limit_conn_dry_run (ngx_http_limit_conn_module)

limit_conn_dry_run (ngx_stream_limit_conn_module)

limit_conn_log_level (ngx_http_limit_conn_module)

limit_conn_log_level (ngx_stream_limit_conn_module)

limit_conn_status

limit_conn_zone (ngx_http_limit_conn_module)

limit_conn_zone (ngx_stream_limit_conn_module)

limit_except

limit_rate

limit_rate_after

limit_req

limit_req_dry_run

limit_req_log_level

limit_req_status

limit_req_zone

limit_zone

lingering_close

lingering_time

lingering_timeout

listen (ngx_http_core_module)

listen (ngx_mail_core_module)

listen (ngx_stream_core_module)

load_module

location

lock_file

log_format (ngx_http_log_module)

log_format (ngx_stream_log_module)

log_not_found

log_subrequest

mail

map (ngx_http_map_module)

map (ngx_stream_map_module)

map_hash_bucket_size (ngx_http_map_module)

map_hash_bucket_size (ngx_stream_map_module)

map_hash_max_size (ngx_http_map_module)

map_hash_max_size (ngx_stream_map_module)

master_process

match (ngx_http_upstream_hc_module)

match (ngx_stream_upstream_hc_module)

max_ranges

memcached_bind

memcached_buffer_size

memcached_connect_timeout

memcached_force_ranges

memcached_gzip_flag

memcached_next_upstream

memcached_next_upstream_timeout

memcached_next_upstream_tries

memcached_pass

memcached_read_timeout

memcached_send_timeout

memcached_socket_keepalive

merge_slashes

min_delete_depth

mirror

mirror_request_body

modern_browser

modern_browser_value

mp4

mp4_buffer_size

mp4_limit_rate

mp4_limit_rate_after

mp4_max_buffer_size

msie_padding

msie_refresh

multi_accept

ntlm

open_file_cache

open_file_cache_errors

open_file_cache_min_uses

open_file_cache_valid

open_log_file_cache (ngx_http_log_module)

open_log_file_cache (ngx_stream_log_module)

output_buffers

override_charset

pcre_jit

perl

perl_modules

perl_require

perl_set

pid

pop3_auth

pop3_capabilities

port_in_redirect

postpone_output

preread_buffer_size

preread_timeout

protocol

proxy_bind (ngx_http_proxy_module)

proxy_bind (ngx_stream_proxy_module)

proxy_buffer

proxy_buffer_size (ngx_http_proxy_module)

proxy_buffer_size (ngx_stream_proxy_module)

proxy_buffering

proxy_buffers

proxy_busy_buffers_size

proxy_cache

proxy_cache_background_update

proxy_cache_bypass

proxy_cache_convert_head

proxy_cache_key

proxy_cache_lock

proxy_cache_lock_age

proxy_cache_lock_timeout

proxy_cache_max_range_offset

proxy_cache_methods

proxy_cache_min_uses

proxy_cache_path

proxy_cache_purge

proxy_cache_revalidate

proxy_cache_use_stale

proxy_cache_valid

proxy_connect_timeout (ngx_http_proxy_module)

proxy_connect_timeout (ngx_stream_proxy_module)

proxy_cookie_domain

proxy_cookie_path

proxy_download_rate

proxy_force_ranges

proxy_headers_hash_bucket_size

proxy_headers_hash_max_size

proxy_hide_header

proxy_http_version

proxy_ignore_client_abort

proxy_ignore_headers

proxy_intercept_errors

proxy_limit_rate

proxy_max_temp_file_size

proxy_method

proxy_next_upstream (ngx_http_proxy_module)

proxy_next_upstream (ngx_stream_proxy_module)

proxy_next_upstream_timeout (ngx_http_proxy_module)

proxy_next_upstream_timeout (ngx_stream_proxy_module)

proxy_next_upstream_tries (ngx_http_proxy_module)

proxy_next_upstream_tries (ngx_stream_proxy_module)

proxy_no_cache

proxy_pass (ngx_http_proxy_module)

proxy_pass (ngx_stream_proxy_module)

proxy_pass_error_message

proxy_pass_header

proxy_pass_request_body

proxy_pass_request_headers

proxy_protocol

proxy_protocol_timeout

proxy_read_timeout

proxy_redirect

proxy_request_buffering

proxy_requests

proxy_responses

proxy_send_lowat

proxy_send_timeout

proxy_session_drop

proxy_set_body

proxy_set_header

proxy_socket_keepalive (ngx_http_proxy_module)

proxy_socket_keepalive (ngx_stream_proxy_module)

proxy_ssl

proxy_ssl_certificate (ngx_http_proxy_module)

proxy_ssl_certificate (ngx_stream_proxy_module)

proxy_ssl_certificate_key (ngx_http_proxy_module)

proxy_ssl_certificate_key (ngx_stream_proxy_module)

proxy_ssl_ciphers (ngx_http_proxy_module)

proxy_ssl_ciphers (ngx_stream_proxy_module)

proxy_ssl_crl (ngx_http_proxy_module)

proxy_ssl_crl (ngx_stream_proxy_module)

proxy_ssl_name (ngx_http_proxy_module)

proxy_ssl_name (ngx_stream_proxy_module)

proxy_ssl_password_file (ngx_http_proxy_module)

proxy_ssl_password_file (ngx_stream_proxy_module)

proxy_ssl_protocols (ngx_http_proxy_module)

proxy_ssl_protocols (ngx_stream_proxy_module)

proxy_ssl_server_name (ngx_http_proxy_module)

proxy_ssl_server_name (ngx_stream_proxy_module)

proxy_ssl_session_reuse (ngx_http_proxy_module)

proxy_ssl_session_reuse (ngx_stream_proxy_module)

proxy_ssl_trusted_certificate (ngx_http_proxy_module)

proxy_ssl_trusted_certificate (ngx_stream_proxy_module)

proxy_ssl_verify (ngx_http_proxy_module)

proxy_ssl_verify (ngx_stream_proxy_module)

proxy_ssl_verify_depth (ngx_http_proxy_module)

proxy_ssl_verify_depth (ngx_stream_proxy_module)

proxy_store

proxy_store_access

proxy_temp_file_write_size

proxy_temp_path

proxy_timeout (ngx_mail_proxy_module)

proxy_timeout (ngx_stream_proxy_module)

proxy_upload_rate

queue

random (ngx_http_upstream_module)

random (ngx_stream_upstream_module)

random_index

read_ahead

real_ip_header

real_ip_recursive

recursive_error_pages

referer_hash_bucket_size

referer_hash_max_size

request_pool_size

reset_timedout_connection

resolver (ngx_http_core_module)

resolver (ngx_http_upstream_module)

resolver (ngx_mail_core_module)

resolver (ngx_stream_core_module)

resolver (ngx_stream_upstream_module)

resolver_timeout (ngx_http_core_module)

resolver_timeout (ngx_http_upstream_module)

resolver_timeout (ngx_mail_core_module)

resolver_timeout (ngx_stream_core_module)

resolver_timeout (ngx_stream_upstream_module)

return (ngx_http_rewrite_module)

return (ngx_stream_return_module)

rewrite

rewrite_log

root

satisfy

scgi_bind

scgi_buffer_size

scgi_buffering

scgi_buffers

scgi_busy_buffers_size

scgi_cache

scgi_cache_background_update

scgi_cache_bypass

scgi_cache_key

scgi_cache_lock

scgi_cache_lock_age

scgi_cache_lock_timeout

scgi_cache_max_range_offset

scgi_cache_methods

scgi_cache_min_uses

scgi_cache_path

scgi_cache_purge

scgi_cache_revalidate

scgi_cache_use_stale

scgi_cache_valid

scgi_connect_timeout

scgi_force_ranges

scgi_hide_header

scgi_ignore_client_abort

scgi_ignore_headers

scgi_intercept_errors

scgi_limit_rate

scgi_max_temp_file_size

scgi_next_upstream

scgi_next_upstream_timeout

scgi_next_upstream_tries

scgi_no_cache

scgi_param

scgi_pass

scgi_pass_header

scgi_pass_request_body

scgi_pass_request_headers

scgi_read_timeout

scgi_request_buffering

scgi_send_timeout

scgi_socket_keepalive

scgi_store

scgi_store_access

scgi_temp_file_write_size

scgi_temp_path

secure_link

secure_link_md5

secure_link_secret

send_lowat

send_timeout

sendfile

sendfile_max_chunk

server (ngx_http_core_module)

server (ngx_http_upstream_module)

server (ngx_mail_core_module)

server (ngx_stream_core_module)

server (ngx_stream_upstream_module)

server_name (ngx_http_core_module)

server_name (ngx_mail_core_module)

server_name_in_redirect

server_names_hash_bucket_size

server_names_hash_max_size

server_tokens

session_log

session_log_format

session_log_zone

set

set_real_ip_from (ngx_http_realip_module)

set_real_ip_from (ngx_stream_realip_module)

slice

smtp_auth

smtp_capabilities

smtp_client_buffer

smtp_greeting_delay

source_charset

spdy_chunk_size

spdy_headers_comp

split_clients (ngx_http_split_clients_module)

split_clients (ngx_stream_split_clients_module)

ssi

ssi_last_modified

ssi_min_file_chunk

ssi_silent_errors

ssi_types

ssi_value_length

ssl (ngx_http_ssl_module)

ssl (ngx_mail_ssl_module)

ssl_buffer_size

ssl_certificate (ngx_http_ssl_module)

ssl_certificate (ngx_mail_ssl_module)

ssl_certificate (ngx_stream_ssl_module)

ssl_certificate_key (ngx_http_ssl_module)

ssl_certificate_key (ngx_mail_ssl_module)

ssl_certificate_key (ngx_stream_ssl_module)

ssl_ciphers (ngx_http_ssl_module)

ssl_ciphers (ngx_mail_ssl_module)

ssl_ciphers (ngx_stream_ssl_module)

ssl_client_certificate (ngx_http_ssl_module)

ssl_client_certificate (ngx_mail_ssl_module)

ssl_client_certificate (ngx_stream_ssl_module)

ssl_crl (ngx_http_ssl_module)

ssl_crl (ngx_mail_ssl_module)

ssl_crl (ngx_stream_ssl_module)

ssl_dhparam (ngx_http_ssl_module)

ssl_dhparam (ngx_mail_ssl_module)

ssl_dhparam (ngx_stream_ssl_module)

ssl_early_data

ssl_ecdh_curve (ngx_http_ssl_module)

ssl_ecdh_curve (ngx_mail_ssl_module)

ssl_ecdh_curve (ngx_stream_ssl_module)

ssl_engine

ssl_handshake_timeout

ssl_ocsp

ssl_ocsp_cache

ssl_ocsp_responder

ssl_password_file (ngx_http_ssl_module)

ssl_password_file (ngx_mail_ssl_module)

ssl_password_file (ngx_stream_ssl_module)

ssl_prefer_server_ciphers (ngx_http_ssl_module)

ssl_prefer_server_ciphers (ngx_mail_ssl_module)

ssl_prefer_server_ciphers (ngx_stream_ssl_module)

ssl_preread

ssl_protocols (ngx_http_ssl_module)

ssl_protocols (ngx_mail_ssl_module)

ssl_protocols (ngx_stream_ssl_module)

ssl_session_cache (ngx_http_ssl_module)

ssl_session_cache (ngx_mail_ssl_module)

ssl_session_cache (ngx_stream_ssl_module)

ssl_session_ticket_key (ngx_http_ssl_module)

ssl_session_ticket_key (ngx_mail_ssl_module)

ssl_session_ticket_key (ngx_stream_ssl_module)

ssl_session_tickets (ngx_http_ssl_module)

ssl_session_tickets (ngx_mail_ssl_module)

ssl_session_tickets (ngx_stream_ssl_module)

ssl_session_timeout (ngx_http_ssl_module)

ssl_session_timeout (ngx_mail_ssl_module)

ssl_session_timeout (ngx_stream_ssl_module)

ssl_stapling

ssl_stapling_file

ssl_stapling_responder

ssl_stapling_verify

ssl_trusted_certificate (ngx_http_ssl_module)

ssl_trusted_certificate (ngx_mail_ssl_module)

ssl_trusted_certificate (ngx_stream_ssl_module)

ssl_verify_client (ngx_http_ssl_module)

ssl_verify_client (ngx_mail_ssl_module)

ssl_verify_client (ngx_stream_ssl_module)

ssl_verify_depth (ngx_http_ssl_module)

ssl_verify_depth (ngx_mail_ssl_module)

ssl_verify_depth (ngx_stream_ssl_module)

starttls

state (ngx_http_upstream_module)

state (ngx_stream_upstream_module)

status

status_format

status_zone (ngx_http_api_module)

status_zone (ngx_http_status_module)

sticky

sticky_cookie_insert

stream

stub_status

sub_filter

sub_filter_last_modified

sub_filter_once

sub_filter_types

subrequest_output_buffer_size

tcp_nodelay (ngx_http_core_module)

tcp_nodelay (ngx_stream_core_module)

tcp_nopush

thread_pool

timeout

timer_resolution

try_files

types

types_hash_bucket_size

types_hash_max_size

underscores_in_headers

uninitialized_variable_warn

upstream (ngx_http_upstream_module)

upstream (ngx_stream_upstream_module)

upstream_conf

use

user

userid

userid_domain

userid_expires

userid_mark

userid_name

userid_p3p

userid_path

userid_service

uwsgi_bind

uwsgi_buffer_size

uwsgi_buffering

uwsgi_buffers

uwsgi_busy_buffers_size

uwsgi_cache

uwsgi_cache_background_update

uwsgi_cache_bypass

uwsgi_cache_key

uwsgi_cache_lock

uwsgi_cache_lock_age

uwsgi_cache_lock_timeout

uwsgi_cache_max_range_offset

uwsgi_cache_methods

uwsgi_cache_min_uses

uwsgi_cache_path

uwsgi_cache_purge

uwsgi_cache_revalidate

uwsgi_cache_use_stale

uwsgi_cache_valid

uwsgi_connect_timeout

uwsgi_force_ranges

uwsgi_hide_header

uwsgi_ignore_client_abort

uwsgi_ignore_headers

uwsgi_intercept_errors

uwsgi_limit_rate

uwsgi_max_temp_file_size

uwsgi_modifier1

uwsgi_modifier2

uwsgi_next_upstream

uwsgi_next_upstream_timeout

uwsgi_next_upstream_tries

uwsgi_no_cache

uwsgi_param

uwsgi_pass

uwsgi_pass_header

uwsgi_pass_request_body

uwsgi_pass_request_headers

uwsgi_read_timeout

uwsgi_request_buffering

uwsgi_send_timeout

uwsgi_socket_keepalive

uwsgi_ssl_certificate

uwsgi_ssl_certificate_key

uwsgi_ssl_ciphers

uwsgi_ssl_crl

uwsgi_ssl_name

uwsgi_ssl_password_file

uwsgi_ssl_protocols

uwsgi_ssl_server_name

uwsgi_ssl_session_reuse

uwsgi_ssl_trusted_certificate

uwsgi_ssl_verify

uwsgi_ssl_verify_depth

uwsgi_store

uwsgi_store_access

uwsgi_temp_file_write_size

uwsgi_temp_path

valid_referers

variables_hash_bucket_size (ngx_http_core_module)

variables_hash_bucket_size (ngx_stream_core_module)

variables_hash_max_size (ngx_http_core_module)

variables_hash_max_size (ngx_stream_core_module)

worker_aio_requests

worker_connections

worker_cpu_affinity

worker_priority

worker_processes

worker_rlimit_core

worker_rlimit_nofile

worker_shutdown_timeout

working_directory

xclient

xml_entities

xslt_last_modified

xslt_param

xslt_string_param

xslt_stylesheet

xslt_types

zone (ngx_http_upstream_module)

zone (ngx_stream_upstream_module)

zone_sync

zone_sync_buffers

zone_sync_connect_retry_interval

zone_sync_connect_timeout

zone_sync_interval

zone_sync_recv_buffer_size

zone_sync_server

zone_sync_ssl

zone_sync_ssl_certificate

zone_sync_ssl_certificate_key

zone_sync_ssl_ciphers

zone_sync_ssl_crl

zone_sync_ssl_name

zone_sync_ssl_password_file

zone_sync_ssl_protocols

zone_sync_ssl_server_name

zone_sync_ssl_trusted_certificate

zone_sync_ssl_verify

zone_sync_ssl_verify_depth

zone_sync_timeout

    1. 变量
    2. 核心功能

属于nginx核心功能的指令包括:

序号

指令名

备注

accept_mutex

accept_mutex_delay

daemon

debug_connection

debug_points

env

error_log

events

include

load_module

lock_file

master_process

multi_accept

pcre_jit

pid

ssl_engine

thread_pool

timer_resolution

use

user

worker_aio_requests

worker_connections

worker_cpu_affinity

worker_priority

worker_processes

worker_rlimit_core

worker_rlimit_nofile

worker_shutdown_timeout

working_directory

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

noodle_bear

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值