

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

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

**重要**  
 AWS OpsWorks Stacks 此服務已於 2024 年 5 月 26 日終止，並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問，請透過 [AWS re：Post](https://repost.aws/) 或透過 [AWS Premium Support](https://aws.amazon.com/support) 聯絡 AWS 支援 團隊。

**注意**  
這些屬性僅適用於 Linux 堆疊。

[`nginx` 屬性](https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/nginx/attributes/nginx.rb)指定 [Nginx](http://wiki.nginx.org/Main) 組態。如需詳細資訊，請參閱 [Directive Index](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) | [user ](#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]
```

**user **  <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]
```