@@ -1094,6 +1094,221 @@ proxy_set_header Accept-Encoding "";
1094
1094
1095
1095
指定一个包含已撤销证书(CRL)的 PEM 格式的文件(` file ` ),用于[ 验证] ( #proxy_ssl_verify ) HTTPS 代理服务器的证书。
1096
1096
1097
+ ### proxy_ssl_name
1098
+
1099
+ | \- | 说明|
1100
+ | ------:| ------|
1101
+ | ** 语法** | ** proxy_ssl_name** ` name ` ;|
1102
+ | ** 默认** | proxy_ssl_name $proxy_host;|
1103
+ | ** 上下文** | http、server、location|
1104
+ | ** 提示** | 该指令在 1.7.0 版本中出现|
1105
+
1106
+ 允许覆盖用于[ 验证] ( #proxy_ssl_verify ) HTTPS 代理服务器证书的服务器名称,并在与 HTTPS 代理服务器建立连接时[ 通过 SNI 传送] ( #proxy_ssl_server_name ) 。
1107
+
1108
+ 默认情况下,使用 [ proxy_pass] ( #proxy_pass ) URL 的 host 部分。
1109
+
1110
+ ### proxy_ssl_password_file
1111
+
1112
+ | \- | 说明|
1113
+ | ------:| ------|
1114
+ | ** 语法** | ** proxy_ssl_password_file** ` file ` ;|
1115
+ | ** 默认** | ——|
1116
+ | ** 上下文** | http、server、location|
1117
+ | ** 提示** | 该指令在 1.7.8 版本中出现|
1118
+
1119
+ 为[ 密钥] ( #proxy_ssl_certificate_key ) 指定一个密码文件(` file ` ),每个密码单独占一行。在加载密钥时依次尝试这些密码。
1120
+
1121
+ ### proxy_ssl_protocols
1122
+
1123
+ | \- | 说明|
1124
+ | ------:| ------|
1125
+ | ** 语法** | ** proxy_ssl_protocols** ` [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2] [TLSv1.3] ` ;|
1126
+ | ** 默认** | proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;|
1127
+ | ** 上下文** | http、server、location|
1128
+ | ** 提示** | 该指令在 1.5.6 版本中出现|
1129
+
1130
+ 为 HTTPS 代理服务器请求启用指定的协议。
1131
+
1132
+ ### proxy_ssl_server_name
1133
+
1134
+ | \- | 说明|
1135
+ | ------:| ------|
1136
+ | ** 语法** | ** proxy_ssl_server_name** ` on ` | ; ` off ` ;|
1137
+ | ** 默认** | proxy_ssl_server_name off;|
1138
+ | ** 上下文** | http、server、location|
1139
+ | ** 提示** | 该指令在 1.7.0 版本中出现|
1140
+
1141
+ 在与 HTTPS 代理服务器建立连接时,启用或禁用通过 [ TLS 服务器名称指示扩展] ( http://en.wikipedia.org/wiki/Server_Name_Indication ) (SNI,RFC 6066)传递服务器名称。
1142
+
1143
+ ### proxy_ssl_session_reuse
1144
+
1145
+ | \- | 说明|
1146
+ | ------:| ------|
1147
+ | ** 语法** | ** proxy_ssl_session_reuse** ` on ` | ; ` off ` ;|
1148
+ | ** 默认** | proxy_ssl_session_reuse on;|
1149
+ | ** 上下文** | http、server、location|
1150
+
1151
+ 确定在使用代理服务器时是否可以复用 SSL 会话。如果日志中出现错误 ` SSL3_GET_FINISHED:digest check failed ` ,请尝试禁用会话复用。
1152
+
1153
+ ### proxy_ssl_trusted_certificate
1154
+
1155
+ | \- | 说明|
1156
+ | ------:| ------|
1157
+ | ** 语法** | ** proxy_ssl_trusted_certificate** ` file ` ;|
1158
+ | ** 默认** | ——|
1159
+ | ** 上下文** | http、server、location|
1160
+ | ** 提示** | 该指令在 1.7.0 版本中出现|
1161
+
1162
+ 指定 PEM 格式的可信 CA 证书文件,用于[ 验证] ( #proxy_ssl_verify ) HTTPS 代理服务器证书。
1163
+
1164
+ ### proxy_ssl_verify
1165
+
1166
+ | \- | 说明|
1167
+ | ------:| ------|
1168
+ | ** 语法** | ** proxy_ssl_verify** ` on ` | ; ` off ` ;|
1169
+ | ** 默认** | proxy_ssl_verify off;|
1170
+ | ** 上下文** | http、server、location|
1171
+ | ** 提示** | 该指令在 1.7.0 版本中出现|
1172
+
1173
+ 启用或禁用验证 HTTPS 代理服务器证书。
1174
+
1175
+ ### proxy_ssl_verify_depth
1176
+
1177
+ | \- | 说明|
1178
+ | ------:| ------|
1179
+ | ** 语法** | ** proxy_ssl_verify_depth** ` number ` ;|
1180
+ | ** 默认** | proxy_ssl_verify_depth 1;|
1181
+ | ** 上下文** | http、server、location|
1182
+ | ** 提示** | 该指令在 1.7.0 版本中出现|
1183
+
1184
+ 设置代理的 HTTPS 服务器证书链验证深度。
1185
+
1186
+ ### proxy_store
1187
+
1188
+ | \- | 说明|
1189
+ | ------:| ------|
1190
+ | ** 语法** | ** proxy_store** ` on ` | ; ` off ` | ; ` string ` ;|
1191
+ | ** 默认** | proxy_store off;|
1192
+ | ** 上下文** | http、server、location|
1193
+
1194
+ 允许将文件保存到磁盘。` on ` 参数使用与 [ alias] ( ngx_http_core_module.md#alias ) 或 [ root] ( ngx_http_core_module.md#root ) 指令对应的路径保存文件。` off ` 参数禁用文件保存。此外,可以使用带变量的字符串显式设置文件名:
1195
+
1196
+ ``` nginx
1197
+ proxy_store /data/www$original_uri;
1198
+ ```
1199
+
1200
+ 根据接收的 ** Last-Modified** 响应 header 字段设置文件的修改时间。首先将响应写入临时文件,然后重命名该文件。从 0.8.9 版本开始,临时文件和持久化存储可以放在不同的文件系统上。但是,请注意,在这种情况下,文件复制需要跨越两个文件系统,而不是简单的重命名操作。因此,建议由 [ proxy_temp_path] ( #proxy_temp_path ) 指令设置的保存文件和保存临时文件的目录都放在同一文件系统上。
1201
+
1202
+ 该指令可用于创建静态不可更改文件的本地副本,例如:
1203
+
1204
+ ``` nginx
1205
+ location /images/ {
1206
+ root /data/www;
1207
+ error_page 404 = /fetch$uri;
1208
+ }
1209
+
1210
+ location /fetch/ {
1211
+ internal;
1212
+
1213
+ proxy_pass http://backend/;
1214
+ proxy_store on;
1215
+ proxy_store_access user:rw group:rw all:r;
1216
+ proxy_temp_path /data/temp;
1217
+
1218
+ alias /data/www/;
1219
+ }
1220
+ ```
1221
+
1222
+ 或者:
1223
+
1224
+ ``` nginx
1225
+ location /images/ {
1226
+ root /data/www;
1227
+ error_page 404 = @fetch;
1228
+ }
1229
+
1230
+ location @fetch {
1231
+ internal;
1232
+
1233
+ proxy_pass http://backend;
1234
+ proxy_store on;
1235
+ proxy_store_access user:rw group:rw all:r;
1236
+ proxy_temp_path /data/temp;
1237
+
1238
+ root /data/www;
1239
+ }
1240
+ ```
1241
+
1242
+ ### proxy_store_access
1243
+
1244
+ | \- | 说明|
1245
+ | ------:| ------|
1246
+ | ** 语法** | ** proxy_store_access** ` users:permissions ... ` ;|
1247
+ | ** 默认** | proxy_store_access user: rw ;|
1248
+ | ** 上下文** | http、server、location|
1249
+
1250
+ 为新创建的文件和目录设置访问权限,例如:
1251
+
1252
+ ``` nginx
1253
+ proxy_store_access user:rw group:rw all:r;
1254
+ ```
1255
+
1256
+ 如果指定了任何 ` group ` 或 ` all ` 访问权限,则可以省略用户权限:
1257
+
1258
+ ``` nginx
1259
+ proxy_store_access group:rw all:r;
1260
+ ```
1261
+
1262
+ ### proxy_temp_file_write_size
1263
+
1264
+ | \- | 说明|
1265
+ | ------:| ------|
1266
+ | ** 语法** | ** proxy_temp_file_write_size** ` size ` ;|
1267
+ | ** 默认** | proxy_temp_file_write_size 8k| ; 16k;|
1268
+ | ** 上下文** | http、server、location|
1269
+
1270
+ 当启用缓冲从代理服务器到临时文件的响应时,限制一次写入临时文件的数据大小(` size ` )。 默认情况下,` size ` 由 [ proxy_buffer_size] ( #proxy_buffer_size ) 和 [ proxy_buffers] ( #proxy_buffers ) 指令设置的两个缓冲区限制。临时文件的最大大小由 [ proxy_max_temp_file_size] ( #proxy_max_temp_file_size ) 指令设置。
1271
+
1272
+ ### proxy_temp_path
1273
+
1274
+ | \- | 说明|
1275
+ | ------:| ------|
1276
+ | ** 语法** | ** proxy_temp_path** ` path [level1 [level2 [level3]]] ` ;|
1277
+ | ** 默认** | proxy_temp_path proxy_temp;|
1278
+ | ** 上下文** | http、server、location|
1279
+
1280
+ 定义用于存储临时文件的目录,其中包含从代理服务器接收的数据。在指定目录下最多可有三级子目录。例如在以下配置
1281
+
1282
+ ``` nginx
1283
+ proxy_temp_path /spool/nginx/proxy_temp 1 2;
1284
+ ```
1285
+
1286
+ 临时文件可能如下:
1287
+
1288
+ ``` nginx
1289
+ /spool/nginx/proxy_temp/7/45/00000123457
1290
+ ```
1291
+
1292
+ 另请参阅 [ proxy_cache_path] ( #proxy_cache_path ) 指令的 ` use_temp_path ` 参数。
1293
+
1294
+ <a id =" embedded_variables " ></a >
1295
+
1296
+ ## 内嵌变量
1297
+
1298
+ ` ngx_http_proxy_module ` 模块支持内嵌变量,可使用 [ proxy_set_header] ( #proxy_set_header ) 指令来聚合 header:
1299
+
1300
+ - ` $proxy_host `
1301
+
1302
+ [ proxy_pass] ( #proxy_pass ) 指令中指定的代理服务器的名称和端口
1303
+
1304
+ - ` $proxy_port `
1305
+
1306
+ [ proxy_pass] ( #proxy_pass ) 指令中指定的代理服务器的端口或协议的默认端口
1307
+
1308
+ - ` $proxy_add_x_forwarded_for `
1309
+
1310
+ ** X-Forwarded-For** 客户端请求头字段,其中附加了 ` $remote_addr ` 变量,以逗号分割。如果客户端请求头中不存在 ** X-Forwarded-For”** 字段,则 ` $proxy_add_x_forwarded_for ` 变量等于 ` $remote_addr ` 变量。
1311
+
1097
1312
** 待续……**
1098
1313
1099
1314
## 原文档
0 commit comments