

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# nginx 属性
<a name="attributes-recipes-nginx"></a>

**重要**  
该 AWS OpsWorks Stacks 服务于 2024 年 5 月 26 日终止，新客户和现有客户均已禁用。我们强烈建议客户尽快将其工作负载迁移到其他解决方案。如果您对迁移有疑问，请通过 re [AWS : Post 或通过 Pre](https://repost.aws/) mium Su [AWS pp](https://aws.amazon.com/support) ort 与 AWS 支持 团队联系。

**注意**  
这些属性仅在 Linux 堆栈上可用。

[`nginx` 属性](https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/nginx/attributes/nginx.rb)指定 [Nginx](http://wiki.nginx.org/Main) 配置。有关更多信息，请参阅[指令索引](http://wiki.nginx.org/DirectiveIndex)。有关如何覆盖内置属性以指定自定义值的更多信息，请参阅 [覆盖属性](workingcookbook-attributes.md)。


****  

|  |  |  | 
| --- |--- |--- |
| [binary ](#attributes-recipes-nginx-binary) | [dir ](#attributes-recipes-nginx-dir) | [gzip ](#attributes-recipes-nginx-gzip) | 
| [gzip\$1comp\$1level ](#attributes-recipes-nginx-gzip-comp) | [gzip\$1disable ](#attributes-recipes-nginx-gzip-disable) | [gzip\$1http\$1version ](#attributes-recipes-nginx-gzip-http) | 
| [gzip\$1proxied ](#attributes-recipes-nginx-gzip-proxied) | [gzip\$1static ](#attributes-recipes-nginx-gzip-static) | [gzip\$1types ](#attributes-recipes-nginx-gzip-types) | 
| [gzip\$1vary ](#attributes-recipes-nginx-gzip-vary) | [keepalive ](#attributes-recipes-nginx-keepalive) | [keepalive\$1timeout ](#attributes-recipes-nginx-keepalive-timeout) | 
| [log\$1dir ](#attributes-recipes-nginx-log) | [用户 ](#attributes-recipes-nginx-user) | [server\$1names\$1hash\$1bucket\$1size](#attributes-recipes-nginx-worker-hash) | 
| [worker\$1processes ](#attributes-recipes-nginx-worker-processes) | [worker\$1connections ](#attributes-recipes-nginx-worker-connections) |  | 

**binary **  <a name="attributes-recipes-nginx-binary"></a>
Nginx 二进制文件的位置 (字符串)。默认值为 `'/usr/sbin/nginx'`。  

```
node[:nginx][:binary]
```

**dir **  <a name="attributes-recipes-nginx-dir"></a>
诸如配置文件之类的文件的位置 (字符串)。默认值为 `'/etc/nginx'`。  

```
node[:nginx][:dir]
```

**gzip **  <a name="attributes-recipes-nginx-gzip"></a>
是否启用 gzip 压缩 (字符串)。可能的值为 `'on'` 和 `'off'`。默认值为 `'on'`。  
压缩可能会带来安全风险。要完全禁用压缩，请按如下方式设置此属性：  

```
node[:nginx][:gzip] = 'off'
```

```
node[:nginx][:gzip]
```

**gzip\$1comp\$1level **  <a name="attributes-recipes-nginx-gzip-comp"></a>
压缩级别，范围为 1 至 9，其中 1 对应于最低程度的压缩 (字符串)。默认值为 `'2'`。  

```
node[:nginx][:gzip_comp_level]
```

**gzip\$1disable **  <a name="attributes-recipes-nginx-gzip-disable"></a>
对指定的用户代理禁用 gzip 压缩 (字符串)。该值是一个正则表达式，默认值为 `'MSIE [1-6].(?!.*SV1)'`。  

```
node[:nginx][:gzip_disable]
```

**gzip\$1http\$1version **  <a name="attributes-recipes-nginx-gzip-http"></a>
对指定的 HTTP 版本启用 gzip 压缩 (字符串)。默认值为 `'1.0'`。  

```
node[:nginx][:gzip_http_version]
```

**gzip\$1proxied **  <a name="attributes-recipes-nginx-gzip-proxied"></a>
是否压缩代理请求的响应以及如何压缩，可以使用以下任一值 (字符串)：  
+ `'off'`：不压缩代理请求
+ `'expired'`：如果 Expire 标头阻止缓存，则压缩
+ `'no-cache'`：如果 Cache-Control 标头设置为“no-cache”，则压缩
+ `'no-store'`：如果 Cache-Control 标头设置为“no-store”，则压缩
+ `'private'`：如果 Cache-Control 标头设置为“private”，则压缩
+ `'no_last_modified'`：如果未设置 Last-Modified，则压缩
+ `'no_etag'`: 如果请求缺少 ETag标头，则压缩
+ `'auth'`：如果请求包含 Authorization 标头，则压缩
+ `'any'`：压缩所有代理请求 
默认值为 `'any'`。  

```
node[:nginx][:gzip_proxied]
```

**gzip\$1static **  <a name="attributes-recipes-nginx-gzip-static"></a>
是否启用 gzip 静态模块 (字符串)。可能的值为 `'on'` 和 `'off'`。默认值为 `'on'`。  

```
node[:nginx][:gzip_static]
```

**gzip\$1types **  <a name="attributes-recipes-nginx-gzip-types"></a>
要压缩的 MIME 类型的列表 (字符串列表)。默认值为 `['text/plain', 'text/html', 'text/css', 'application/x-javascript', 'text/xml', 'application/xml', 'application/xml+rss', 'text/javascript']`。  

```
node[:nginx][:gzip_types]
```

**gzip\$1vary **  <a name="attributes-recipes-nginx-gzip-vary"></a>
是否启用 `Vary:Accept-Encoding ` 响应标头 (字符串)。可能的值为 `'on'` 和 `'off'`。默认值为 `'on'`。  

```
node[:nginx][:gzip_vary]
```

**keepalive **  <a name="attributes-recipes-nginx-keepalive"></a>
是否启用保持活动连接 (字符串)。可能的值为 `'on'` 和 `'off'`。默认值为 `'on'`。  

```
node[:nginx][:keepalive]
```

**keepalive\$1timeout **  <a name="attributes-recipes-nginx-keepalive-timeout"></a>
保持活动的连接处于打开状态的最长时间 (秒) (数字)。默认值为 `65`。  

```
node[:nginx][:keepalive_timeout]
```

**log\$1dir **  <a name="attributes-recipes-nginx-log"></a>
日志文件的位置 (字符串)。默认值为 `'/var/log/nginx'`。  

```
node[:nginx][:log_dir]
```

**用户 **  <a name="attributes-recipes-nginx-user"></a>
用户 (字符串)。默认值如下所示：  
+ Amazon Linux 和 RHEL: `'www-data'`
+ Ubuntu: `'nginx'`

```
node[:nginx][:user]
```

**server\$1names\$1hash\$1bucket\$1size**  <a name="attributes-recipes-nginx-worker-hash"></a>
服务器名称哈希表的存储桶大小，该值可设置为 `32`、`64` 或 `128` (数字)。默认值为 `64`。  

```
node[:nginx][:server_names_hash_bucket_size]
```

**worker\$1processes **  <a name="attributes-recipes-nginx-worker-processes"></a>
工作进程数 (数字)。默认值为 `10`。  

```
node[:nginx][:worker_processes]
```

**worker\$1connections **  <a name="attributes-recipes-nginx-worker-connections"></a>
最大工作线程连接数 (数字)。默认值为 `1024`。最大客户端数设置为 `worker_processes * worker_connections`。  

```
node[:nginx][:worker_connections]
```