- add-headers
- allow-backend-server-header
- allow-cross-namespace-resources
- allow-snippet-annotations
- annotations-risk-level
- annotation-value-word-blocklist
- hide-headers
- access-log-params
- access-log-path
- http-access-log-path
- stream-access-log-path
- enable-access-log-for-default-backend
- error-log-path
- enable-modsecurity
- enable-owasp-modsecurity-crs
- modsecurity-snippet
- client-header-buffer-size
- client-header-timeout
- client-body-buffer-size
- client-body-timeout
- disable-access-log
- disable-ipv6
- disable-ipv6-dns
- enable-underscores-in-headers
- enable-ocsp
- ignore-invalid-headers
- retry-non-idempotent
- error-log-level
- http2-max-field-size
- http2-max-header-size
- http2-max-requests
- http2-max-concurrent-streams
- hsts
- hsts-include-subdomains
- hsts-max-age
- hsts-preload
- keep-alive
- keep-alive-requests
- large-client-header-buffers
- log-format-escape-none
- log-format-escape-json
- log-format-upstream
- log-format-stream
- enable-multi-accept
- max-worker-connections
- max-worker-open-files
- map-hash-bucket-size
- proxy-real-ip-cidr
- proxy-set-headers
- server-name-hash-max-size
- server-name-hash-bucket-size
- proxy-headers-hash-max-size
- reuse-port
- proxy-headers-hash-bucket-size
- server-tokens
- ssl-ciphers
以下是 ConfigMaps 配置选项的后续翻译内容:
add-headers
设置从指定 ConfigMap 中读取的自定义头部,这些头部会在流量发送到客户端之前添加。参见 proxy-set-headers。示例
allow-backend-server-header
允许返回来自后端的 Server 头部,而不是通用的 nginx 字符串。默认值: 禁用
allow-cross-namespace-resources
允许用户通过注解消费跨命名空间的资源。默认值: false
受此变更影响的注解包括:
• auth-secret
• auth-proxy-set-header
• auth-tls-secret
• fastcgi-params-configmap
• proxy-ssl-secret
allow-snippet-annotations
允许 Ingress 解析并添加用户创建的 -snippet 注解/指令。默认值:_ false
警告:建议仅在信任具有创建 Ingress 对象权限的用户时启用此选项,因为这可能允许用户在最终的 nginx.conf 文件中添加受限配置。
annotations-risk-level
表示注解可接受的风险级别。例如,如果风险级别为 Medium
,则高风险和关键风险的注解将不被接受。
可接受的值包括 Critical
、High
、Medium
和 Low
。默认值: High
annotation-value-word-blocklist
包含以逗号分隔的字符/单词列表,这些字符/单词已知被滥用于 Ingress 配置,必须被阻止。与 CVE-2021-25742 相关。
当检测到注解值包含被阻止的不良单词时,整个 Ingress 将不会被配置。默认值: ""
覆盖此默认值时,Ingress 管理员应添加所有需要阻止的单词,以下是建议的阻止列表:
建议值: "load_module,lua_package,_by_lua,location,root,proxy_pass,serviceaccount,{,},',\""
hide-headers
设置不会从上游服务器传递到客户端响应的额外头部。默认值: 空
参考: https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header
access-log-params
为 access_log 设置额外参数。例如:buffer=16k, gzip, flush=1m
参考: https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
access-log-path
HTTP 和 stream 上下文的访问日志路径。默认为 /var/log/nginx/access.log
。
注意: 文件 /var/log/nginx/access.log
是 /dev/stdout
的符号链接。
http-access-log-path
全局 HTTP 上下文的访问日志路径。默认值: “”
注意: 如果未指定,将使用 access-log-path
。
stream-access-log-path
全局 stream 上下文的访问日志路径。默认值: “”
注意: 如果未指定,将使用 access-log-path
。
enable-access-log-for-default-backend
启用对默认后端的访问日志记录。默认值: 禁用。
error-log-path
错误日志路径。默认为 /var/log/nginx/error.log
。
注意: 文件 /var/log/nginx/error.log
是 /dev/stderr
的符号链接。
参考: https://nginx.org/en/docs/ngx_core_module.html#error_log
enable-modsecurity
为 NGINX 启用 modsecurity 模块。默认值: 禁用
enable-owasp-modsecurity-crs
启用 OWASP ModSecurity 核心规则集 (CRS)。默认值: 禁用
modsecurity-snippet
向 nginx 配置的 modsecurity 部分添加自定义规则。
client-header-buffer-size
配置用于读取客户端请求头部的自定义缓冲区大小。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size
client-header-timeout
定义读取客户端请求头部的超时时间(秒)。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout
client-body-buffer-size
设置用于读取客户端请求主体的缓冲区大小。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size
client-body-timeout
定义读取客户端请求主体的超时时间(秒)。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout
disable-access-log
禁用整个 Ingress Controller 的访问日志。默认值: false
参考: https://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
disable-ipv6
禁用 IPv6 监听。默认值: false
;IPv6 监听默认启用。
disable-ipv6-dns
禁用 nginx DNS 解析器的 IPv6 支持。默认值: false
;IPv6 解析默认启用。
enable-underscores-in-headers
允许在头部名称中使用下划线。默认值: 禁用
enable-ocsp
启用在线证书状态协议装订 (OCSP) 支持。默认值: 禁用
ignore-invalid-headers
设置是否应忽略名称无效的头部字段。默认值: 启用
retry-non-idempotent
自 1.9.13 版本起,NGINX 在上游服务器出错时不会重试非幂等请求(POST、LOCK、PATCH)。使用值 “true” 可以恢复之前的行为。
error-log-level
配置错误日志的日志级别。日志级别按严重程度递增排列。
参考: https://nginx.org/en/docs/ngx_core_module.html#error_log
http2-max-field-size
警告
此功能已在 1.1.3 版本中弃用,并将在 1.3.0 版本中移除。请改用 large-client-header-buffers。
限制 HPACK 压缩请求头部字段的最大大小。
参考: https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_field_size
http2-max-header-size
警告
此功能已在 1.1.3 版本中弃用,并将在 1.3.0 版本中移除。请改用 large-client-header-buffers。
限制 HPACK 解压缩后整个请求头部列表的最大大小。
参考: https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_header_size
http2-max-requests
警告
此功能已在 1.1.3 版本中弃用,并将在 1.3.0 版本中移除。请改用 upstream-keepalive-requests。
设置通过一个 HTTP/2 连接可以服务的最大请求数(包括推送请求),超过此数量后,下一个客户端请求将导致连接关闭并需要建立新连接。
参考: https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_requests
http2-max-concurrent-streams
设置一个连接中并发的 HTTP/2 流的最大数量。
参考: https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_concurrent_streams
hsts
在运行 SSL 的服务器上启用或禁用 HSTS 头部。HTTP 严格传输安全(通常缩写为 HSTS)是一种安全功能(HTTP 头部),告诉浏览器应仅使用 HTTPS 进行通信,而不是使用 HTTP。它提供了针对协议降级攻击和 cookie 窃取的保护。
参考: • https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security • https://blog.qualys.com/securitylabs/2016/03/28/the-importance-of-a-proper-http-strict-transport-security-implementation-on-your-web-server
hsts-include-subdomains
启用或禁用对服务器名称的所有子域使用 HSTS。
hsts-max-age
设置浏览器应记住此站点仅可通过 HTTPS 访问的时间(秒)。
hsts-preload
在 HSTS 功能中启用或禁用 preload 属性(当启用时)。
keep-alive
设置一个保持活动的客户端连接在服务器端保持打开的时间(秒)。零值禁用保持活动的客户端连接。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
重要提示
设置 keep-alive: '0'
很可能会中断并发的 http/2 请求,因为 nginx 1.19.7 引入了变更。
`nginx 1.19.7 的变更 16 Feb 2021
*) 变更: HTTP/2 中的连接处理已更改以更好地匹配 HTTP/1.x;已移除 "http2_recv_timeout"、"http2_idle_timeout" 和 "http2_max_requests" 指令,应改用 "keepalive_timeout" 和 "keepalive_requests" 指令。`
参考: nginx 变更日志 nginx 问题跟踪器 nginx 邮件列表
keep-alive-requests
设置可以通过一个保持活动连接服务的最大请求数。
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_requests
large-client-header-buffers
设置用于读取大型客户端请求头部的缓冲区的最大数量和大小。默认值: 4 8k
参考: https://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers
log-format-escape-none
设置是否完全禁用变量中的字符转义(”true”)或由 log-format-escape-json 控制(”false”)。设置 nginx 日志格式。
log-format-escape-json
设置转义参数是否允许 JSON(”true”)或变量中的默认字符转义(”false”)。设置 nginx 日志格式。
log-format-upstream
设置 nginx 日志格式。JSON 输出的示例:
log-format-upstream: '{"time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr", "x_forwarded_for": "$proxy_add_x_forwarded_for", "request_id": "$req_id",
"remote_user": "$remote_user", "bytes_sent": $bytes_sent, "request_time": $request_time, "status": $status, "vhost": "$host", "request_proto": "$server_protocol",
"path": "$uri", "request_query": "$args", "request_length": $request_length, "duration": $request_time,"method": "$request_method", "http_referrer": "$http_referer",
"http_user_agent": "$http_user_agent" }'
请查看 log-format 了解每个字段的定义。
log-format-stream
设置 nginx stream 格式。
enable-multi-accept
如果禁用,工作进程将一次接受一个新连接。否则,工作进程将一次接受所有新连接。默认值: true
参考: https://nginx.org/en/docs/ngx_core_module.html#multi_accept
max-worker-connections
设置每个工作进程可以打开的同时连接的最大数量。0 将使用 max-worker-open-files 的值。默认值: 16384
提示
在高负载场景中使用 0 可以提高性能,但会增加 RAM 使用率(即使在空闲时)。
max-worker-open-files
设置每个工作进程可以打开的文件的最大数量。默认值 0 表示”最大打开文件数(系统限制)- 1024”。默认值: 0
map-hash-bucket-size
设置 map 变量哈希表的桶大小。哈希表设置的详细信息在单独的文档中提供。
proxy-real-ip-cidr
如果启用了 use-forwarded-headers
或 use-proxy-protocol
,proxy-real-ip-cidr
定义外部负载均衡器的默认 IP/网络地址。可以是 CIDR 块的逗号分隔列表。默认值: “0.0.0.0/0”
proxy-set-headers
设置从指定 ConfigMap 中读取的自定义头部,这些头部会在流量发送到后端之前添加。值格式为 namespace/name。参见示例
server-name-hash-max-size
设置服务器名称哈希表的最大大小,这些哈希表用于服务器名称、map 指令的值、MIME 类型、请求头部字符串名称等。
参考: https://nginx.org/en/docs/hash.html
server-name-hash-bucket-size
设置服务器名称哈希表的桶大小。
参考: • https://nginx.org/en/docs/hash.html • https://nginx.org/en/docs/http/ngx_http_core_module.html#server_names_hash_bucket_size
proxy-headers-hash-max-size
设置代理头部哈希表的最大大小。
参考: • https://nginx.org/en/docs/hash.html • https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_headers_hash_max_size
reuse-port
指示 NGINX 为每个工作进程创建单独的监听套接字(使用 SOREUSEPORT 套接字选项),允许内核在工作进程之间分配传入连接。默认值:_ true
proxy-headers-hash-bucket-size
设置代理头部哈希表的桶大小。
参考: • https://nginx.org/en/docs/hash.html • https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_headers_hash_bucket_size
server-tokens
在响应中发送 NGINX Server 头部并在错误页面中显示 NGINX 版本。默认值: 禁用
ssl-ciphers
设置启用的 ciphers 列表。密码以 OpenSSL 库理解的格式指定。
默认密码列表为:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
。
密码套件的顺序非常重要,因为它决定了优先选择哪些算法。上述建议优先考虑提供完美[前向保密](https://wiki.mozilla.org/Security/Server