nginx-ingress配置卷(ConfigMaps)nginx-configuration翻译

本文介绍了Nginx控制器的配置参数,包括访问日志路径、错误日志路径、SSL设置、连接超时、代理设置、压缩、安全性和自定义HTTP错误等。此外,还提到了配置映射哈希桶大小、代理协议头超时、日志格式、代理缓冲区大小等高级设置,以及启用或禁用各种特性,如开启HSTS、使用Brotli压缩和多路复用等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ConfigMaps

ConfigMap允许您将配置工件与图像内容分离,以使容器化的应用程序具有可移植性。

ConfigMap API资源将配置数据存储为键值对。该数据为Nginx控制器提供了系统组件的配置。

为了覆盖config.go中所示的nginx-controller配置值,您可以将键值对添加到config-map的data部分。例如:

data:
  map-hash-bucket-size: "128"
  ssl-protocols: SSLv2

重要

ConfigMap中的键和值只能是字符串。这意味着我们想要一个带有布尔值的值,我们需要用引号将它们引号,例如“ true”或“ false”。数字也一样,例如“ 100”。

可以将Slice类型(以下定义为[]string[]int)作为逗号分隔的字符串。

Configuration options

下表显示了配置选项的名称,类型和默认值:

nametypedefault
add-headersstring""
allow-backend-server-headerbool"false"
hide-headersstring arrayempty
access-log-paramsstring""
access-log-pathstring"/var/log/nginx/access.log"
http-access-log-pathstring""
stream-access-log-pathstring""
enable-access-log-for-default-backendbool"false"
error-log-pathstring"/var/log/nginx/error.log"
enable-modsecuritybool"false"
modsecurity-snippetstring""
enable-owasp-modsecurity-crsbool"false"
client-header-buffer-sizestring"1k"
client-header-timeoutint60
client-body-buffer-sizestring"8k"
client-body-timeoutint60
disable-access-logboolfalse
disable-ipv6boolfalse
disable-ipv6-dnsboolfalse
enable-underscores-in-headersboolfalse
enable-ocspboolfalse
ignore-invalid-headersbooltrue
retry-non-idempotentbool"false"
error-log-levelstring"notice"
http2-max-field-sizestring"4k"
http2-max-header-sizestring"16k"
http2-max-requestsint1000
http2-max-concurrent-streamsint1000
hstsbool"true"
hsts-include-subdomainsbool"true"
hsts-max-agestring"15724800"
hsts-preloadbool"false"
keep-aliveint75
keep-alive-requestsint100
large-client-header-buffersstring"4 8k"
log-format-escape-jsonbool"false"
log-format-upstreamstring$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id
log-format-streamstring[$remote_addr] [$time_local] $protocol $status $bytes_sent $bytes_received $session_time
enable-multi-acceptbool"true"
max-worker-connectionsint16384
max-worker-open-filesint0
map-hash-bucket-sizeint64
nginx-status-ipv4-whitelist[]string"127.0.0.1"
nginx-status-ipv6-whitelist[]string"::1"
proxy-real-ip-cidr[]string"0.0.0.0/0"
proxy-set-headersstring""
server-name-hash-max-sizeint1024
server-name-hash-bucket-sizeint<size of the processor’s cache line>
proxy-headers-hash-max-sizeint512
proxy-headers-hash-bucket-sizeint64
plugins[]string 
reuse-portbool"true"
server-tokensbool"false"
ssl-ciphersstring"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"
ssl-ecdh-curvestring"auto"
ssl-dh-paramstring""
ssl-protocolsstring"TLSv1.2 TLSv1.3"
ssl-session-cachebool"true"
ssl-session-cache-sizestring"10m"
ssl-session-ticketsbool"false"
ssl-session-ticket-keystring<Randomly Generated>
ssl-session-timeoutstring"10m"
ssl-buffer-sizestring"4k"
use-proxy-protocolbool"false"
proxy-protocol-header-timeoutstring"5s"
use-gzipbool"false"
use-geoipbool"true"
use-geoip2bool"false"
enable-brotlibool"false"
brotli-levelint4
brotli-typesstring"application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component"
use-http2bool"true"
gzip-levelint1
gzip-typesstring"application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component"
worker-processesstring<Number of CPUs>
worker-cpu-affinitystring""
worker-shutdown-timeoutstring"240s"
load-balancestring"round_robin"
variables-hash-bucket-sizeint128
variables-hash-max-sizeint2048
upstream-keepalive-connectionsint320
upstream-keepalive-timeoutint60
upstream-keepalive-requestsint10000
limit-conn-zone-variablestring"$binary_remote_addr"
proxy-stream-timeoutstring"600s"
proxy-stream-next-upstreambool"true"
proxy-stream-next-upstream-timeoutstring"600s"
proxy-stream-next-upstream-triesint3
proxy-stream-responsesint1
bind-address[]string""
use-forwarded-headersbool"false"
enable-real-ipbool"false"
forwarded-for-headerstring"X-Forwarded-For"
compute-full-forwarded-forbool"false"
proxy-add-original-uri-headerbool"false"
generate-request-idbool"true"
enable-opentracingbool"false"
opentracing-operation-namestring""
opentracing-location-operation-namestring""
zipkin-collector-hoststring""
zipkin-collector-portint9411
zipkin-service-namestring"nginx"
zipkin-sample-ratefloat1.0
jaeger-collector-hoststring""
jaeger-collector-portint6831
jaeger-service-namestring"nginx"
jaeger-sampler-typestring"const"
jaeger-sampler-paramstring"1"
jaeger-sampler-hoststring"http://127.0.0.1"
jaeger-sampler-portint5778
jaeger-trace-context-header-namestringuber-trace-id
jaeger-debug-headerstringuber-debug-id
jaeger-baggage-headerstringjaeger-baggage
jaeger-trace-baggage-header-prefixstringuberctx-
datadog-collector-hoststring""
datadog-collector-portint8126
datadog-service-namestring"nginx"
datadog-environmentstring"prod"
datadog-operation-name-overridestring"nginx.handle"
datadog-priority-samplingbool"true"
datadog-sample-ratefloat1.0
main-snippetstring""
http-snippetstring""
server-snippetstring""
location-snippetstring""
custom-http-errors[]int[]int
proxy-body-sizestring"1m"
proxy-connect-timeoutint5
proxy-read-timeoutint60
proxy-send-timeoutint60
proxy-buffers-numberint4
proxy-buffer-sizestring"4k"
proxy-cookie-pathstring"off"
proxy-cookie-domainstring"off"
proxy-next-upstreamstring"error timeout"
proxy-next-upstream-timeoutint0
proxy-next-upstream-triesint3
proxy-redirect-fromstring"off"
proxy-request-bufferingstring"on"
ssl-redirectbool"true"
whitelist-source-range[]string[]string
skip-access-log-urls[]string[]string
limit-rateint0
limit-rate-afterint0
lua-shared-dictsstring""
http-redirect-codeint308
proxy-bufferingstring"off"
limit-req-status-codeint503
limit-conn-status-codeint503
no-tls-redirect-locationsstring"/.well-known/acme-challenge"
global-auth-urlstring""
global-auth-methodstring""
global-auth-signinstring""
global-auth-signin-redirect-paramstring"rd"
global-auth-response-headersstring""
global-auth-request-redirectstring""
global-auth-snippetstring""
global-auth-cache-keystring""
global-auth-cache-durationstring"200 202 401 5m"
no-auth-locationsstring"/.well-known/acme-challenge"
block-cidrs[]string""
block-user-agents[]string""
block-referers[]string""
proxy-ssl-location-onlybool"false"
default-typestring"text/html"

add-headers

在将流量发送到客户端之前,从命名的configmap设置自定义标头。请参阅proxy-set-headers

allow-backend-server-header

启用从后端返回标头服务器,而不是从通用nginx字符串返回。default: is disabled

hide-headers

设置不会从上游服务器传递到客户端响应的其他标头。 default: empty

参考: http //nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header

access-log-params

access_log的其他参数。例如,buffer = 16k,gzip,flush = 1m

参考: http //nginx.org/en/docs/http/ngx_http_log_module.html#access_log

 

access-log-path

http和流上下文的访问日志路径。/var/log/nginx/access.log默认情况下转到。

注意:该文件/var/log/nginx/access.log是指向的符号链接/dev/stdout

http-access-log-path

全局访问http上下文的日志路径。 default: ""

注意:如果未指定,access-log-path将使用。

stream-access-log-path

全局访问流上下文的日志路径。 default: ""

    •  
目录

ConfigMaps

ConfigMap允许您将配置工件与图像内容分离,以使容器化的应用程序具有可移植性。

ConfigMap API资源将配置数据存储为键值对。该数据为Nginx控制器提供了系统组件的配置。

为了覆盖config.go中所示的nginx-controller配置值,您可以将键值对添加到config-map的data部分。例如:

data:
  map-hash-bucket-size: "128"
  ssl-protocols: SSLv2

重要

ConfigMap中的键和值只能是字符串。这意味着我们想要一个带有布尔值的值,我们需要用引号将它们引号,例如“ true”或“ false”。数字也一样,例如“ 100”。

可以将Slice类型(以下定义为[]string[]int)作为逗号分隔的字符串。

配置选项

下表显示了配置选项的名称,类型和默认值:

名称类型默认
添加标题
允许后端服务器头布尔“假”
隐藏标题字符串数组空的
访问日志参数
访问日志路径“ /var/log/nginx/access.log”
http-access-log-path
流访问日志路径
为默认后端启用访问日志布尔“假”
错误日志路径“ /var/log/nginx/error.log”
启用安全性布尔“假”
modsecurity片段
启用owasp-modsecurity-crs布尔“假”
客户端头缓冲区大小“ 1k”
客户头超时整型60
客户端主体缓冲区大小“ 8k”
客户端超时整型60
禁用访问日志布尔
禁用-ipv6布尔
禁用-ipv6-dns布尔
启用标题下划线布尔
使能布尔
忽略无效的标题布尔真正
重试非幂等布尔“假”
错误日志级别“注意”
http2-max-field-size“ 4k”
http2-max-header-size“ 16k”
http2-max-requests整型1000
http2-max-concurrent-streams整型1000
科技布尔“真正”
hsts-include-subdomains布尔“真正”
最高时长“ 15724800”
hsts-preload布尔“假”
活着整型75
保持活动请求整型100
大客户头缓冲区“ 4 8k”
日志格式转义json布尔“假”
日志格式上游$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id
日志格式流[$remote_addr] [$time_local] $protocol $status $bytes_sent $bytes_received $session_time
启用多重接受布尔“真正”
max-worker-connections整型16384
max-worker-open-files整型0
映射哈希桶大小整型64
nginx-状态-ipv4-白名单[]串“ 127.0.0.1”
nginx-status-ipv6-whitelist[]串“ :: 1”
代理真实IP密码[]串“ 0.0.0.0/0”
代理集标题
服务器名称哈希最大大小整型1024
服务器名称哈希桶大小整型<size of the processor’s cache line>
代理标头哈希最大大小整型512
代理标头哈希桶大小整型64
外挂程式[]串 
重用端口布尔“真正”
服务器令牌布尔“假”
密码“ 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“
ssl-ecdh曲线“汽车”
ssl-dh-param
ssl协议“ TLSv1.2 TLSv1.3”
ssl会话缓存布尔“真正”
ssl会话缓存大小“ 10m”
ssl会话门票布尔“假”
ssl会话票证密钥<Randomly Generated>
ssl会话超时“ 10m”
ssl缓冲区大小“ 4k”
使用代理协议布尔“假”
代理协议头超时“ 5s”
使用gzip布尔“假”
使用地理布尔“真正”
use-geoip2布尔“假”
使能布尔“假”
肉鸡水平整型4
肉鸡型“应用程序/ xml + rss应用程序/ atom + xml应用程序/ javascript应用程序/ x-javascript应用程序/ json应用程序/ rss + xml应用程序/vnd.ms-fontobject应用程序/ x-font-ttf应用程序/ x-web-app-manifest + json应用程序/ xhtml + xml应用程序/ xml字体/ opentype图片/ svg + xml图片/ x-icon文本/ css文本/ javascript文本/纯文本/ x组件”
使用-http2布尔“真正”
gzip级整型1个
gzip类型“应用程序/ atom + xml应用程序/ javascript应用程序/ x-javascript应用程序/ json应用程序/ rss + xml应用程序/vnd.ms-fontobject应用程序/ x-font-ttf应用程序/ x-web-app-manifest + json应用程序/ xhtml + xml应用程序/ xml字体/ opentype图像/ svg + xml图像/ x-icon文本/ css文本/ javascript文本/纯文本/ x组件”
工人过程<Number of CPUs>
工人-CPU亲和力
工人关机超时“ 240s”
负载均衡“ round_robin”
变量哈希桶大小整型128
变量哈希最大大小整型2048
上游-keepalive-连接整型320
上游Keepalive超时整型60
上游keepalive请求整型10000
极限连接区变量“ $ binary_remote_addr”
代理流超时“ 600s”
代理流下一个上游布尔“真正”
代理流下一个上游超时“ 600s”
代理流下一个上游尝试整型3
代理流响应整型1个
绑定地址[]串
使用转发标头布尔“假”
启用真实IP布尔“假”
标题转发“ X-Forwarded-For”
计算完全转发布尔“假”
代理添加原始uri标头布尔“假”
生成请求ID布尔“真正”
启用开放式跟踪布尔“假”
opentracing-操作名称
opentracing-location-operation-name
zipkin-collector-host
zipkin-collector-port整型9411
zipkin服务名称“ nginx”
压缩样本率浮动1.0
jaeger-collector-host
Jaeger-collector-port整型6831
jaeger服务名称“ nginx”
杰格采样器类型“ const”
jaeger-sampler-param“ 1”
jaeger-sampler-host“ http://127.0.0.1”
杰格采样器端口整型5778
jaeger-trace-context-header-名称uber-trace-id
jaeger-debug-headeruber-debug-id
贾格行李箱头积家行李
jaeger-trace-baggage-header-prefixuberctx-
数据狗收集器主机
数据狗收集器端口整型8126
datadog-service-name“ nginx”
数据狗环境“产品”
数据狗操作名称覆盖“ nginx.handle”
数据狗优先采样布尔“真正”
数据狗采样率浮动1.0
主片段
http-片段
服务器片段
位置摘要
自定义http错误[] int[] int
代理主体大小“ 1m”
代理连接超时整型5
代理读取超时整型60
代理发送超时整型60
代理缓冲区编号整型4
代理缓冲区大小“ 4k”
代理cookie路径“关闭”
代理Cookie域“关闭”
代理下一个上游“错误超时”
代理下一个上游超时整型0
代理下一个上游尝试整型3
代理重定向自“关闭”
代理请求缓冲“上”
ssl重定向布尔“真正”
白名单源范围[]串[]串
跳过访问日志网址[]串[]串
极限率整型0
限制后率整型0
lua-share-dicts
http重定向代码整型308
代理缓冲“关闭”
极限要求状态码整型503
极限连接状态码整型503
no-tls-重定向位置“ /。众所周知/ acme挑战”
全局验证网址
全局验证方法
全局身份验证登录
全局验证登录重定向参数“ rd”
全局验证响应头
全局验证请求重定向
全局身份验证代码段
全局验证缓存密钥
全局验证缓存持续时间“ 200 202 401 5m”
无身份验证位置“ /。众所周知/ acme挑战”
块索引[]串
阻止用户代理[]串
区块参照[]串
仅限代理SSL位置布尔“假”
默认类型“文本/ html”

add-headers

在将流量发送到客户端之前,从命名的configmap设置自定义标头。请参阅proxy-set-headers

allow-backend-server-header

启用从后端返回标头服务器,而不是从通用nginx字符串返回。默认值:禁用

hide-headers

设置不会从上游服务器传递到客户端响应的其他标头。 默认值:

参考: http //nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header

access-log-params

access_log的其他参数。例如,buffer = 16k,gzip,flush = 1m

参考: http //nginx.org/en/docs/http/ngx_http_log_module.html#access_log

access-log-path

http和流上下文的访问日志路径。/var/log/nginx/access.log默认情况下转到。

注意:该文件/var/log/nginx/access.log是指向的符号链接/dev/stdout

http-access-log-path

全局访问http上下文的日志路径。 默认值: “”

注意:如果未指定,access-log-path将使用。

stream-access-log-path

全局访问流上下文的日志路径。 默认值: “”

注意:如果未指定,access-log-path将使用。

enable-access-log-for-default-backend

全局访问流上下文的日志路径。default: is disabled.

error-log-path

错误日志路径。/var/log/nginx/error.log默认情况下转到。

注意:该文件/var/log/nginx/error.log是指向的符号链接/dev/stderr

参考: http //nginx.org/en/docs/ngx_core_module.html#error_log

 

enable-modsecurity

为NGINX启用modsecurity模块。 default: is disabled

enable-owasp-modsecurity-crs

启用OWASP ModSecurity核心规则集(CRS)。 default: is disabled

modsecurity-snippet

向Nginx配置的modsecurity部分添加自定义规则

client-header-buffer-size

允许配置自定义缓冲区大小以读取客户端请求标头。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size

 

client-header-timeout

定义读取客户端请求标头的超时(以秒为单位)。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout

 

client-body-buffer-size

设置用于读取客户端请求正文的缓冲区大小。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size

 

client-body-timeout

定义读取客户端请求正文的超时时间(以秒为单位)。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout

 

disable-access-log

从整个Ingress Controller禁用访问日志。 default: '"false"'

参考: http //nginx.org/en/docs/http/ngx_http_log_module.html#access_log

disable-ipv6

禁用监听IPV6。default: false; 已启用IPv6侦听

disable-ipv6-dns

为Nginx DNS解析器禁用IPV6。default: false; 启用了IPv6解析。

enable-underscores-in-headers

在标题名称中启用下划线。 default: is disabled

enable-ocsp

启用在线证书状态协议装订(OCSP)支持。 default: is disabled

ignore-invalid-headers

设置是否忽略具有无效名称的头字段。 default: is enabled

retry-non-idempotent

从1.9.13开始,如果上游服务器发生错误,NGINX将不会重试非幂等请求(POST,LOCK,PATCH)。可以使用值“ true”恢复以前的行为。

error-log-level

配置错误的日志记录级别。以上日志级别按严重性从高到低的顺序列出。

参考: http //nginx.org/en/docs/ngx_core_module.html#error_log

 

http2-max-field-size

限制HPACK压缩的请求标头字段的最大大小。

参考: https //nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_field_size

 

http2-max-header-size

限制HPACK解压缩后整个请求标头列表的最大大小。

参考: https //nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_header_size

 

http2-max-requests

设置可以通过一个HTTP / 2连接提供服务的最大请求数(包括推送请求),之后下一个客户端请求将导致连接关闭以及需要建立新连接。

参考: http //nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_requests

 

http2-max-concurrent-streams

设置连接中并发HTTP / 2流的最大数量。

参考: http //nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_concurrent_streams

 

hsts

在运行SSL的服务器中启用或禁用标头HSTS。HTTP严格传输安全性(通常缩写为HSTS)是一项安全功能(HTTP标头),它告诉浏览器仅应使用HTTPS而不是使用HTTPS进行通信。它提供了针对协议降级攻击和cookie盗窃的保护。

参考文献:

hsts-include-subdomains

在服务器名称的所有子域中启用或禁用HSTS。

hsts-max-age

设置浏览器记住该站点仅使用HTTPS访问的时间(以秒为单位)。

hsts-preload

启用或禁用HSTS功能中的preload属性(启用时)dd

keep-alive

设置保持活动的客户端连接在服务器端保持打开状态的时间。零值将禁用保持活动状态的客户端连接。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout

 

keep-alive-requests

设置可以通过一个保持活动连接服务的最大请求数。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_requests

 

large-client-header-buffers

设置用于读取大型客户端请求标头的缓冲区的最大数量和大小。默认值: 4 8k

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers

 

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_forward_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-stream

设置nginx流格式

enable-multi-accept

如果禁用,则辅助进程将一次接受一个新连接。否则,工作进程将一次接受所有新连接。 默认值: true

参考: http //nginx.org/en/docs/ngx_core_module.html#multi_accept

 

max-worker-connections

设置每个工作进程可以打开的最大同时连接数。0将使用max-worker-open-files的值。  default: 16384

Tip

在高负载的情况下使用0可以提高性能,但以增加RAM利用率(甚至在空闲时)为代价。

max-worker-open-files

设置每个工作进程可以打开的最大文件数。默认值为0表示“最大打开文件数(系统的限制)/ worker-processes -1024”。 default: 0

map-hash-bucket-size

设置映射变量哈希表的存储桶大小。设置哈希表的详细信息在单独的文档中提供。

proxy-real-ip-cidr

如果启用了use-forwarded-header或use-proxy-protocol,则proxy-real-ip-cidr定义默认的外部负载均衡器的IP /网络地址。

proxy-set-headers

在将流量发送到后端之前,从命名的configmap设置自定义标头。值格式为名称空间/名称。看例子

server-name-hash-max-size

设置服务器名称哈希表的最大大小,这些哈希表用于服务器名称,map指令的值,MIME类型,请求标头字符串的名称等。

参考: http //nginx.org/en/docs/hash.html

server-name-hash-bucket-size

设置服务器名称哈希表的存储桶大小。

参考文献:

proxy-headers-hash-max-size

设置代理标头哈希表的最大大小。

参考文献:

reuse-port

指示NGINX为每个工作进程创建一个单独的侦听套接字(使用SO_REUSEPORT套接字选项),从而允许内核在工作进程之间分配传入的连接, default: true

proxy-headers-hash-bucket-size

设置代理标头哈希表的存储桶大小。

参考文献:

plugins

激活安装在中的插件/etc/nginx/lua/plugins。有关如何编写和安装插件的更多信息,请参阅ingress-nginx插件自述文件

server-tokens

在响应中发送NGINX Server标头,并在错误页面中显示NGINX版本。 default: is disabled

ssl-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

密码套件的排序非常重要,因为它决定了优先选择哪些算法。以上建议优先考虑了提供完美前向保密性的算法。

在配置DH参数之前,基于DHE的密码将不可用自定义DH参数可实现完美的前向保密性

请检查Mozilla SSL配置生成器

注意:默认情况下,将为http上下文启用ssl_prefer_server_ciphers指令。

ssl-ecdh-curve

指定ECDHE密码的曲线。

参考: http //nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ecdh_curve

 

ssl-dh-param

设置包含Diffie-Hellman密钥的机密名称,以帮助实现“ Perfect Forward Secrecy”。

参考文献:

ssl-protocols

设置要使用的SSL协议。默认值为:TLSv1.2 TLSv1.3

请使用https://ssllabs.com/ssltest/analyze.html或检查配置结果https://testssl.sh

ssl-early-data

启用或禁用TLS 1.3早期数据,也称为零往返时间恢复(0-RTT)。

这要求ssl-protocols已经TLSv1.3启用。请谨慎启用此功能,因为在早期数据中发送的请求会受到重放攻击

ssl_early_dataThe default is: false.

ssl-session-cache

启用或禁用工作进程之间共享SSL缓存的使用。

ssl-session-cache-size

设置所有工作进程之间的SSL共享会话缓存的大小。

ssl-session-tickets

通过TLS会话票证启用或禁用会话恢复。

ssl-session-ticket-key

设置用于加密和解密TLS会话票证的密钥。该值必须是有效的base64字符串。要创建票证:openssl rand 80 | openssl enc -A -base64

TLS会话票证密钥,默认情况下,使用随机生成的密钥。

ssl-session-timeout

设置客户端可以重复使用存储在缓存中的会话参数的时间。

ssl-buffer-size

设置用于发送数据的SSL缓冲区的大小。默认的4k可以帮助NGINX改善TLS首字节时间(TTTFB)。

参考: https //www.igvita.com/2013/12/16/optimizing-nginx-tls-time-to-first-byte/

 

use-proxy-protocol

启用或禁用PROXY协议,以接收通过代理服务器和负载均衡器(例如HAProxy和Amazon Elastic Load Balancer(ELB))传递的客户端连接(真实IP地址)信息。

proxy-protocol-header-timeout

设置用于接收代理协议标头的超时值。默认值为5秒可防止TLS直通处理程序无限期地等待断开的连接。 default: 5s

use-gzip

使用“ gzip”模块启用或禁用HTTP响应的压缩。要压缩的MIME类型由gzip-types控制。 default: false

use-geoip

使用预编译的MaxMind数据库启用或禁用“ geoip”模块,该模块使用取决于客户端IP地址的值来创建变量。 default: true

注意: MaxMind旧版数据库已停产,并且在2019年1月2日之后将不会接收更新,请参见。停产通知书。考虑下面的use-geoip2

use-geoip2

为NGINX启用geoip2模块。由于0.27.0且由于MaxMind数据库更改,需要许可证才能访问数据库。因此,需要--maxmind-license-key在入口控制器部署中定义一个新标志,以下载在入口控制器初始化期间所需的数据库。另外,也可以使用卷来装载文件/etc/nginx/geoip/GeoLite2-City.mmdb/etc/nginx/geoip/GeoLite2-ASN.mmdb,从而避免了下载的开销。

重要

如果启用了该功能但文件丢失,则不会启用GeoIP2。

default: false

enable-brotli

使用“ brotli”模块启用或禁用HTTP响应的压缩。要压缩的默认mime类型列表为:application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-componentdefault: is disabled

注意: Brotli在Safari <11中不起作用。有关更多信息,请参见https://caniuse.com/#feat=brotli

brotli-level

设置将使用的Brotli压缩级别。default: 4

brotli-types

设置将由brotli即时压缩的MIME类型。 default: application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component

use-http2

在安全连接中启用或禁用HTTP / 2支持。

gzip-level

设置将使用的gzip压缩级别。 default: 1

gzip-min-length

可以进行gzip压缩之前返回给客户端的响应的最小长度(以字节为单位)。 default: 256

gzip-types

设置除“ text / html”以外的MIME类型以进行压缩。特殊值“ *”与任何MIME类型匹配。如果use-gzip启用,则始终压缩“ text / html”类型的响应。 default: application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component.

worker-processes

设置工作进程数。默认值“ auto”表示可用的CPU内核数。

worker-cpu-affinity

将工作进程绑定到CPU组。worker_cpu_affinity。默认情况下,辅助进程未绑定到任何特定的CPU。该值可以是:

  • “”:空字符串表示未应用任何亲和力。
  • cpumask:例如0001 0010 0100 1000,将进程绑定到特定的cpus。
  • auto:将工作进程自动绑定到可用的CPU。

worker-shutdown-timeout

设置Nginx等待工作者正常关闭的超时时间 default: "240s"

load-balance

设置用于负载平衡的算法。该值可以是:

  • round_robin:使用默认的循环负载均衡器
  • ewma:使用Peak EWMA方法进行路由(实现

默认值为round_robin

  • 要使用IP或其他变量的一致哈希进行负载平衡,请考虑nginx.ingress.kubernetes.io/upstream-hash-by注释。
  • 要使用会话cookie进行负载平衡,请考虑nginx.ingress.kubernetes.io/affinity注释。

参考: http //nginx.org/en/docs/http/load_balancing.html

 

variables-hash-bucket-size

设置变量哈希表的存储桶大小。

参考: http //nginx.org/en/docs/http/ngx_http_map_module.html#variables_hash_bucket_size

 

variables-hash-max-size

设置变量哈希表的最大大小。

参考: http //nginx.org/en/docs/http/ngx_http_map_module.html#variables_hash_max_size

 

upstream-keepalive-connections

激活缓存以连接到上游服务器。connections参数设置每个工作进程的高速缓存中保留的与上游服务器的空闲保持连接的最大数量。超过此数量时,将关闭最近最少使用的连接。 default: 320

参考: http //nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

upstream-keepalive-timeout

设置一个超时,在此超时期间,与上游服务器的空闲keepalive连接将保持打开状态。default: 60

References: http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout

upstream-keepalive-requests

设置通过一个keepalive连接可以处理的最大请求数。达到最大请求数后,连接将关闭。 default: 10000

参考: http //nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_requests

limit-conn-zone-variable

设置共享内存区域的参数,该参数将保持limit_conn_zone的各个键的状态。变量“ $ binary_remote_addr”的默认大小始终为4字节(对于IPv4地址)或16字节(对于IPv6地址)。

proxy-stream-timeout

设置客户端或代理服务器连接上两次连续的读取或写入操作之间的超时。如果在此时间内没有数据传输,则连接将关闭。

参考: http //nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout

proxy-stream-next-upstream

如果无法建立与代理服务器的连接,请确定是否将客户端连接传递给下一台服务器。

参考: http //nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream

 

proxy-stream-next-upstream-timeout

限制将连接传递到下一台服务器所允许的时间。0值关闭此限制。

参考: http //nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_timeout

 

proxy-stream-next-upstream-tries

限制将请求传递到下一个服务器的可能尝试次数。0值关闭此限制。

参考: http //nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_tries

 

proxy-stream-responses

如果使用UDP协议,则设置代理服务器响应客户端请求而期望的数据报数。

参考: http //nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses

 

bind-address

设置服务器将接受请求而不是*的地址。应当注意,这些地址必须存在于运行时环境中,否则控制器将崩溃。

use-forwarded-headers

如果为true,NGINX将传入的X-Forwarded-*标头传递给上游。当NGINX位于另一个正在设置这些标头的L7代理/负载平衡器之后时,请使用此选项。

如果为false,则NGINX将忽略传入的X-Forwarded-*标头,并用看到的请求信息填充它们。如果NGINX直接暴露于Internet或位于基于L3 /数据包的负载均衡器之后,而该负载均衡器不会更改数据包中的源IP,请使用此选项。

enable-real-ip

enable-real-ip启用http://nginx.org/en/docs/http/ngx_http_realip_module.html的配置。可以使用forwarded-for-headerproxy-real-ip-cidr设置进一步配置模块的特定属性。

forwarded-for-header

设置标头字段,用于标识客户端的原始IP地址。 default: X-Forwarded-For

compute-full-forwarded-for

将远程地址附加到X-Forwarded-For标头,而不是替换它。启用此选项后,上游应用程序将根据自己的受信任代理列表提取客户端IP。

proxy-add-original-uri-header

将具有原始请求URI的X-Original-Uri标头添加到后端请求

generate-request-id

如果请求中不存在X-Request-ID,则确保X-Request-ID默认为随机值

enable-opentracing

启用nginx Opentracing扩展。default: is disabled

References: https://github.com/opentracing-contrib/nginx-opentracing

opentracing-operation-name

指定服务器范围的自定义名称。 default: is empty

例如,设置为"HTTP $request_method $uri".

opentracing-location-operation-name

指定位置范围的自定义名称。default: is empty

例如,设置为"HTTP $request_method $uri".

zipkin-collector-host

指定上载跟踪时要使用的主机。它必须是一个有效的URL。

zipkin-collector-port

指定上载跟踪时要使用的端口。 default: 9411

zipkin-service-name

指定用于创建的任何跟踪的服务名称。default: nginx

zipkin-sample-rate

指定创建的任何跟踪的采样率。default: 1.0

jaeger-collector-host

指定上载跟踪时要使用的主机。它必须是一个有效的URL。

jaeger-collector-port

指定上载跟踪时要使用的端口。default: 6831

jaeger-service-name

指定用于创建的任何跟踪的服务名称。default: nginx

jaeger-sampler-type

指定采样轨迹时要使用的采样器。可用的采样器有:const,概率,速率限制,远程。 default: const

jaeger-sampler-param

指定要传递给采样器构造函数的参数。必须是数字。对于const,应为0(从不采样)和1(始终采样)。default: 1

jaeger-sampler-host

指定要传递给采样器构造函数的自定义远程采样器主机。必须是有效的网址。保留空白以使用默认值(localhost)。 default: http://127.0.0.1

jaeger-sampler-port

指定要传递给采样器构造函数的自定义远程采样器端口。必须是数字。default: 5778

jaeger-trace-context-header-name

指定用于传递跟踪上下文的标头名称。 default: uber-trace-id

jaeger-debug-header

指定用于强制采样的标题名称。 default: jaeger-debug-id

jaeger-baggage-header

指定没有根跨度时用于提交行李的标头名称。default: jaeger-baggage

jaeger-tracer-baggage-header-prefix

指定用于传播行李的标题前缀。 default: uberctx-

datadog-collector-host

指定上载跟踪时要使用的datadog代理主机。它必须是一个有效的URL。

datadog-collector-port

指定上载跟踪时要使用的端口。 default: 8126

datadog-service-name

指定用于创建的任何跟踪的服务名称。 default: nginx

datadog-environment

指定此跟踪所属的环境。default: prod

datadog-operation-name-override

覆盖用于创建任何痕迹的操作名。default: nginx.handle

datadog-priority-sampling

指定使用客户端采样。如果为true,则禁用客户端采样(因此忽略sample_rate)并启用分布式优先级采样,其中基于用户分配的优先级和来自代理的配置的组合对跟踪进行采样。 default: true

datadog-sample-rate

指定创建的任何跟踪的采样率。只有当这是有效datadog-priority-samplingfalse default: 1.0

main-snippet

将自定义配置添加到nginx配置的主要部分。

http-snippet

将自定义配置添加到nginx配置的http部分。

server-snippet

将自定义配置添加到nginx配置中的所有服务器。

location-snippet

将自定义配置添加到nginx配置中的所有位置。

您不能使用它来添加代理到Kubernetes容器的新位置,因为该片段无法访问Go模板功能。如果要添加自定义位置,则必须提供自己的nginx.tmpl

custom-http-errors

启用应使用error_page指令传递哪些HTTP代码进行处理

设置至少一个代码还使得proxy_intercept_errors它们都需要处理error_page。

用法示例: custom-http-errors: 404,415

proxy-body-size

设置客户端请求正文的最大允许大小。参见NGINX client_max_body_size

proxy-connect-timeout

设置与代理服务器建立连接的超时。请注意,此超时通常不能超过75秒。

proxy-read-timeout

设置以秒为单位的超时时间,以从代理服务器读取响应。超时仅在两次连续的读取操作之间设置,而不用于传输整个响应。

proxy-send-timeout

以秒为单位设置将请求传输到代理服务器的超时时间。超时仅在两个连续的写操作之间设置,而不用于整个请求的传输。

proxy-buffers-number

设置用于读取从代理服务器接收到的响应的第一部分的缓冲区的编号。这部分通常包含一个小的响应头。

proxy-buffer-size

设置用于读取从代理服务器接收到的响应的第一部分的缓冲区的大小。这部分通常包含一个小的响应头。

设置应在代理服务器响应的“ Set-Cookie”标头字段的path属性更改的文本。

设置应在代理服务器响应的“ Set-Cookie”标头字段的domain属性更改的文本。

proxy-next-upstream

指定在哪种情况下将请求传递到下一个服务器。

proxy-next-upstream-timeout

限制可以将请求传递到下一台服务器的时间(以秒为单位)。

proxy-next-upstream-tries

限制将请求传递到下一个服务器的可能尝试次数。

proxy-redirect-from

设置应在代理服务器响应的“位置”和“刷新”标头字段中更改的原始文本。 default: off

参考: http //nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect

proxy-request-buffering

启用或禁用客户端请求正文的缓冲

ssl-redirect

如果服务器具有TLS证书(在Ingress规则中定义),则将重定向(301)的全局值设置为HTTPS。default: "true"

whitelist-source-range

为每个server块设置默认的白名单IP 。这可以由Ingress规则上的注释覆盖。参见ngx_http_access_module

skip-access-log-urls

设置不应出现在NGINX访问日志中的URL列表。这对于类似/healthhealth-check使“复杂”读取日志的url很有用。 default: is empty

limit-rate

限制向客户端传输响应的速率。该速率以每秒字节数指定。零值禁用速率限制。该限制是根据请求设置的,因此,如果客户端同时打开两个连接,则总速率将是指定限制的两倍。

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#limit_rate

 

limit-rate-after

设置初始数量,之后将进一步限制对客户端的响应的进一步传输。

lua-shared-dicts

自定义默认的Lua共享字典或定义更多。您可以使用以下语法来这样做:

lua-shared-dicts: "<my dict name>: <my dict size>, [<my dict name>: <my dict size>], ..."

例如,以下将默认certificate_data字典设置为100M,并引入了一个新字典,名为 my_custom_plugin

lua-shared-dicts: "certificate_data: 100, my_custom_plugin: 5"

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#limit_rate_after

http-redirect-code

设置要在重定向中使用的HTTP状态代码。支持代码301302307308 default: 308

为什么默认代码是308?

创建RFC 7238是为了定义308(永久重定向)状态代码,该状态代码类似于301(永久移动),但它将有效负载保留在重定向中。如果我们以POST之类的方法发送重定向,这一点很重要。

proxy-buffering

启用或禁用代理服务器响应的缓冲

limit-req-status-code

设置状态代码以响应被拒绝的请求而返回。 default: 503

limit-conn-status-code

设置状态代码以响应拒绝的连接而返回。 default: 503

no-tls-redirect-locations

以逗号分隔的位置列表,在这些位置上,http请求永远不会重定向到其https副本。default: "/.well-known/acme-challenge"

global-auth-url

nginx.ingress.kubernetes.io/auth-url。可以使用no-auth-locationsSee no-auth-locations列出不应该通过身份验证的位置。另外,可以通过enable-global-auth设置为“ false”的注释将每个服务从身份验证中排除。 default: ""

参考文献: https //github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md#external-authentication

global-auth-method

一种用于现有服务的HTTP方法,该服务为所有位置提供身份验证。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-methoddefault: ""

global-auth-signin

为现有服务设置错误页面的位置,该服务为所有位置提供身份验证。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-signin。 default: ""

global-auth-signin-redirect-param

在错误页面登录URL中设置查询参数,该URL包含身份验证失败的请求的原始URL。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-signin-redirect-param。 default: "rd"

global-auth-response-headers

将头设置为在身份验证请求完成后传递到后端。应用于所有位置。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-response-headersdefault: ""

global-auth-request-redirect

设置X-Auth-Request-Redirect标头值。应用于所有位置。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-request-redirectdefault: ""

global-auth-snippet

设置自定义代码段以与外部身份验证一起使用。应用于所有位置。类似于Ingress规则注释nginx.ingress.kubernetes.io/auth-request-redirect。 default: ""

global-auth-cache-key

为全局身份验证请求启用缓存。指定用于身份验证响应的查找键,例如$remote_user$http_authorization

global-auth-cache-duration

根据验证响应的响应代码(例如)设置缓存时间200 202 30m。有关详细信息,请参见proxy_cache_valid。您可以指定多个逗号分隔的值:200 202 10m, 401 5m。默认为200 202 401 5m

no-auth-locations

以逗号分隔的不应该通过身份验证的位置列表。 default: "/.well-known/acme-challenge"

block-cidrs

以逗号分隔的IP地址(或子网)列表,必须全局阻止来自该IP地址(或子网)的请求。

参考: http //nginx.org/en/docs/http/ngx_http_access_module.html#deny

 

block-user-agents

以逗号分隔的User-Agent列表,必须全局阻止来自该列表的请求。在这里可以使用完整的字符串和正则表达式。有关有效模式的更多详细信息,可以在mapNginx指令文档中找到。

参考: http //nginx.org/en/docs/http/ngx_http_map_module.html#map

 

block-referers

以逗号分隔的“引荐来源”列表,必须全局阻止来自其的请求。在这里可以使用完整的字符串和正则表达式。有关有效模式的更多详细信息,可以在mapNginx指令文档中找到。

参考: http //nginx.org/en/docs/http/ngx_http_map_module.html#map

 

proxy-ssl-location-only

设置是否将proxy-ssl参数仅应用于位置而不应用于服务器。default: is disabled

default-type

设置响应的默认MIME类型。default: text/html

参考: http //nginx.org/en/docs/http/ngx_http_core_module.html#default_type

参考配置

apiVersion: v1
kind: ConfigMap
data:
  allow-backend-server-header: "true"
  compute-full-forwarded-for: "true"
  enable-brotli: "true"
  enable-modsecurity: "true"
  enable-ocsp: "true"
  enable-owasp-modsecurity-crs: "true"
  enable-underscores-in-headers: "true"
  generate-request-id: "true"
  hsts-preload: "true"
  ignore-invalid-headers: "true"
  keep-alive-requests: "10000"
  log-format-upstream: $remote_addr - [$proxy_add_x_forwarded_for] - $remote_user
    [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
    $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length
    $upstream_response_time $upstream_status $req_id $host [$proxy_alternative_upstream_name]
  max-worker-connections: "65535"
  proxy-body-size: 20m
  proxy-connect-timeout: "1"
  proxy-read-timeout: "3"
  proxy-send-timeout: "3"
  reuse-port: "true"
  server-tokens: "false"
  ssl-protocols: TLSv1.2 TLSv1.3
  ssl-redirect: "false"
  ssl-session-cache: "true"
  ssl-session-cache-size: 5m
  ssl-session-ticket-key: yAl9Gs5LFBlfiWqmdCLVQCt7KVMXbYuYVOHhT1PD9w5OQWIFQ2SwsKhNBJ5FhninuR3tX6CpSDe2tnQOExJ2JCmvwSLfPUWL0PDeRJpEnJ0=
  ssl-session-tickets: "true"
  ssl-session-timeout: 60m
  upstream-keepalive-connections: "200"
  upstream-keepalive-requests: "10000"
  upstream-keepalive-timeout: "100"
  use-forwarded-headers: "true"
  worker-cpu-affinity: auto
  worker-processes: auto

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值