京东云服务器推荐配置、多种配置选择,满足不同业务需求!

热门推荐

⭐ 稳定入门选择

配置:2核2G/5M

适用场景:个人站点 / 轻量应用

特点:性价比高,稳定可靠

¥19/月
立即购买
流量友好

☁️ 轻量云主机

配置:2核4G 5M

适用场景:小型业务 / 博客 / 测试环境

特点:流量友好,性能均衡

¥149/年
立即购买
高性能

💻 云服务主机

配置:4核16G 8M

适用场景:中小型服务 / 多并发场景

特点:充足内存与带宽,性能强劲

¥750/年
立即购买
新人专享

🎁 新人福利

新人访问 → 点击 → 最新活动

可获取 3000元 礼券

立即领取
服务端 / Nginx 教程 / nginx 配置
Nginx指令
Nginx 指令和上下文 Nginx 变量

Nginx 指令

Nginx 由配置文件中定义的指令控制的模块组成。指令分为两部分:

  • 简单指令:简单指令由名称和参数组成,以空格分隔并以分号 ; 结尾。
  • 块指令:块指令的结构类似于简单指令,但它不是以分号结尾,而是以一组用大括号 { 和 } 括起来的附加指令结尾。如果块指令在大括号内包含其他指令,则它被称为上下文 (context)。例如,Events、http、location 和 server。

配置文件中放置在任何上下文之外的指令都被认为是在主上下文中events http 指令在主上下文中server 指令在 http 上下文, location 指令在 server 上下文。

让我们看看一些重要指令的列表:

指令 语法 默认配置 上下文
absolute_redirect absolute_redirect on | off; absolute_redirect on; http, server, location
accept_mutex accept_mutex on | off; off Events
accept_mutex_delay accept_mutex_delay time; accept_mutex_delay 500ms; Events
access_log (ngx_http_log_module) access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];
access_log off;
access_log logs/access.log combined; http, server, location, if in location, limit_except
access_log (ngx_stream_log_module) access_log path format [buffer=size] [gzip[=level]] [flush=time] [if=condition];
access_log off;
access_log off; stream, server
add_after_body add_before_body uri; - http, server, location
add_before_body add_before_body uri; - http, server, location
add_header add_header name value [always]; - http, server, location, if in location
add_trailer add_trailer name value [always]; - http, server, location, if in location
addition_types addition_types mime-type ...; addition_types text/html; http, server, location
aio aio on | off | threads[=pool]; aio off; http, server, location
aio_write aio_write on | off; aio_write off; http, server, location
alias alias path; - Location
allow (ngx_http_access_module) allow address | CIDR | unix: | all; - http, server, location, limit_except
allow (ngx_stream_access_module) allow address | CIDR | unix: | all; - Stream, server
ancient_browser ancient_browser string ...; - http, server, location
ancient_browser_value ancient_browser_value string; ancient_browser_value 1; http, server, location
api api [write=on|off]; - location
auth_basic auth_basic string | off; auth_basic off; http, server, location, limit_except
auth_basic_user_file auth_basic_user_file file; - http, server, location, limit_except
auth_http auth_http URL; - mail, server
auth_http_header auth_http_header header value; - mail, server
auth_http_pass_client_cert auth_http_pass_client_cert on | off; auth_http_pass_client_cert off; mail, server
auth_http_timeout auth_http_timeout time auth_http_timeout 60s; mail, server
auth_jwt auth_jwt string [token=$variable] | off; auth_jwt off; http, server, location, limit_except
auth_jwt_claim_set auth_jwt_claim_set $variable name ...; - http
auth_jwt_header_set auth_jwt_header_set $variable name ...; - http
auth_jwt_key_file auth_jwt_key_file file; - ttp, server, location, limit_except
auth_jwt_key_request      
Nginx 指令和上下文 Nginx 变量
下一篇:Nginx 变量