2016-06-05 13:36:00 +00:00
|
|
|
|
/*
|
2016-09-08 11:02:39 +00:00
|
|
|
|
Copyright 2016 The Kubernetes Authors.
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
2017-03-28 16:39:44 +00:00
|
|
|
|
"strconv"
|
2018-06-04 01:10:41 +00:00
|
|
|
|
"time"
|
2016-11-10 22:56:29 +00:00
|
|
|
|
|
2020-08-08 23:31:02 +00:00
|
|
|
|
"k8s.io/klog/v2"
|
2016-11-16 18:24:26 +00:00
|
|
|
|
|
2017-09-17 20:01:28 +00:00
|
|
|
|
apiv1 "k8s.io/api/core/v1"
|
2017-09-17 18:03:05 +00:00
|
|
|
|
|
2017-11-07 22:02:12 +00:00
|
|
|
|
"k8s.io/ingress-nginx/internal/ingress"
|
|
|
|
|
"k8s.io/ingress-nginx/internal/ingress/defaults"
|
2018-08-25 21:08:12 +00:00
|
|
|
|
"k8s.io/ingress-nginx/internal/runtime"
|
2016-06-05 13:36:00 +00:00
|
|
|
|
)
|
|
|
|
|
|
2019-07-04 22:06:55 +00:00
|
|
|
|
var (
|
|
|
|
|
// EnableSSLChainCompletion Autocomplete SSL certificate chains with missing intermediate CA certificates.
|
|
|
|
|
EnableSSLChainCompletion = false
|
|
|
|
|
)
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
const (
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size
|
|
|
|
|
// Sets the maximum allowed size of the client request body
|
|
|
|
|
bodySize = "1m"
|
|
|
|
|
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#error_log
|
|
|
|
|
// Configures logging level [debug | info | notice | warn | error | crit | alert | emerg]
|
|
|
|
|
// Log levels above are listed in the order of increasing severity
|
|
|
|
|
errorLevel = "notice"
|
|
|
|
|
|
|
|
|
|
// HTTP Strict Transport Security (often abbreviated as HSTS) is a security feature (HTTP header)
|
|
|
|
|
// that tell browsers that it should only be communicated with using HTTPS, instead of using HTTP.
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
|
|
|
|
|
// max-age is the time, in seconds, that the browser should remember that this site is only to be accessed using HTTPS.
|
|
|
|
|
hstsMaxAge = "15724800"
|
|
|
|
|
|
2019-06-06 02:40:16 +00:00
|
|
|
|
gzipTypes = "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"
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2019-06-06 02:40:16 +00:00
|
|
|
|
brotliTypes = "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"
|
2017-10-30 19:32:47 +00:00
|
|
|
|
|
2019-09-12 23:01:33 +00:00
|
|
|
|
logFormatUpstream = `$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`
|
2017-02-27 10:00:31 +00:00
|
|
|
|
|
2019-10-18 01:08:02 +00:00
|
|
|
|
logFormatStream = `[$remote_addr] [$time_local] $protocol $status $bytes_sent $bytes_received $session_time`
|
2017-02-27 10:00:31 +00:00
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size
|
|
|
|
|
// Sets the size of the buffer used for sending data.
|
|
|
|
|
// 4k helps NGINX to improve TLS Time To First Byte (TTTFB)
|
|
|
|
|
// https://www.igvita.com/2013/12/16/optimizing-nginx-tls-time-to-first-byte/
|
|
|
|
|
sslBufferSize = "4k"
|
|
|
|
|
|
|
|
|
|
// Enabled ciphers list to enabled. The ciphers are specified in the format understood by the OpenSSL library
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ciphers
|
2019-12-05 22:34:53 +00:00
|
|
|
|
sslCiphers = "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"
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// SSL enabled protocols to use
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_protocols
|
2020-05-02 11:29:27 +00:00
|
|
|
|
sslProtocols = "TLSv1.2 TLSv1.3"
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2019-08-07 20:04:09 +00:00
|
|
|
|
// Disable TLS 1.3 early data
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_early_data
|
|
|
|
|
sslEarlyData = false
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Time during which a client may reuse the session parameters stored in a cache.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_timeout
|
|
|
|
|
sslSessionTimeout = "10m"
|
|
|
|
|
|
|
|
|
|
// Size of the SSL shared cache between all worker processes.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_cache
|
|
|
|
|
sslSessionCacheSize = "10m"
|
2017-04-28 20:41:53 +00:00
|
|
|
|
|
2017-07-06 23:13:32 +00:00
|
|
|
|
// Parameters for a shared memory zone that will keep states for various keys.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_zone
|
|
|
|
|
defaultLimitConnZoneVariable = "$binary_remote_addr"
|
2016-06-05 13:36:00 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Configuration represents the content of nginx.conf file
|
|
|
|
|
type Configuration struct {
|
2016-12-28 13:08:02 +00:00
|
|
|
|
defaults.Backend `json:",squash"`
|
2016-11-10 22:56:29 +00:00
|
|
|
|
|
2021-09-20 23:52:23 +00:00
|
|
|
|
// AllowSnippetAnnotations enable users to add their own snippets via ingress annotation.
|
2021-09-19 19:40:08 +00:00
|
|
|
|
// If disabled, only snippets added via ConfigMap are added to ingress.
|
2021-09-20 23:52:23 +00:00
|
|
|
|
AllowSnippetAnnotations bool `json:"allow-snippet-annotations"`
|
2021-09-19 19:40:08 +00:00
|
|
|
|
|
2021-11-12 19:40:30 +00:00
|
|
|
|
// AnnotationValueWordBlocklist defines words that should not be part of an user annotation value
|
|
|
|
|
// (can be used to run arbitrary code or configs, for example) and that should be dropped.
|
|
|
|
|
// This list should be separated by "," character
|
|
|
|
|
AnnotationValueWordBlocklist string `json:"annotation-value-word-blocklist"`
|
|
|
|
|
|
2017-05-18 10:21:03 +00:00
|
|
|
|
// Sets the name of the configmap that contains the headers to pass to the client
|
|
|
|
|
AddHeaders string `json:"add-headers,omitempty"`
|
|
|
|
|
|
2017-05-28 21:40:25 +00:00
|
|
|
|
// AllowBackendServerHeader enables the return of the header Server from the backend
|
|
|
|
|
// instead of the generic nginx string.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
AllowBackendServerHeader bool `json:"allow-backend-server-header"`
|
|
|
|
|
|
2019-01-26 17:55:18 +00:00
|
|
|
|
// AccessLogParams sets additionals params for access_log
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
|
|
|
|
// By default it's empty
|
|
|
|
|
AccessLogParams string `json:"access-log-params,omitempty"`
|
|
|
|
|
|
2019-02-19 23:02:01 +00:00
|
|
|
|
// EnableAccessLogForDefaultBackend enable access_log for default backend
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableAccessLogForDefaultBackend bool `json:"enable-access-log-for-default-backend"`
|
|
|
|
|
|
2020-06-04 12:56:41 +00:00
|
|
|
|
// AccessLogPath sets the path of the access logs for both http and stream contexts if enabled
|
2017-08-23 14:57:28 +00:00
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
2020-06-04 12:56:41 +00:00
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_log_module.html#access_log
|
2017-08-23 14:57:28 +00:00
|
|
|
|
// By default access logs go to /var/log/nginx/access.log
|
|
|
|
|
AccessLogPath string `json:"access-log-path,omitempty"`
|
|
|
|
|
|
2020-06-04 12:56:41 +00:00
|
|
|
|
// HttpAccessLogPath sets the path of the access logs for http context globally if enabled
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
|
|
|
|
|
HttpAccessLogPath string `json:"http-access-log-path,omitempty"`
|
|
|
|
|
|
|
|
|
|
// StreamAccessLogPath sets the path of the access logs for stream context globally if enabled
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_log_module.html#access_log
|
|
|
|
|
StreamAccessLogPath string `json:"stream-access-log-path,omitempty"`
|
|
|
|
|
|
2018-10-30 23:46:48 +00:00
|
|
|
|
// WorkerCPUAffinity bind nginx worker processes to CPUs this will improve response latency
|
2018-03-16 16:32:45 +00:00
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity
|
|
|
|
|
// By default this is disabled
|
2018-10-30 23:46:48 +00:00
|
|
|
|
WorkerCPUAffinity string `json:"worker-cpu-affinity,omitempty"`
|
2017-08-23 14:57:28 +00:00
|
|
|
|
// ErrorLogPath sets the path of the error logs
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#error_log
|
|
|
|
|
// By default error logs go to /var/log/nginx/error.log
|
|
|
|
|
ErrorLogPath string `json:"error-log-path,omitempty"`
|
|
|
|
|
|
2017-10-08 14:52:02 +00:00
|
|
|
|
// EnableModsecurity enables the modsecurity module for NGINX
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableModsecurity bool `json:"enable-modsecurity"`
|
|
|
|
|
|
2020-04-17 02:34:12 +00:00
|
|
|
|
// EnableOCSP enables the OCSP support in SSL connections
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableOCSP bool `json:"enable-ocsp"`
|
|
|
|
|
|
2018-11-08 20:17:40 +00:00
|
|
|
|
// EnableOWASPCoreRules enables the OWASP ModSecurity Core Rule Set (CRS)
|
2017-10-08 14:52:02 +00:00
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableOWASPCoreRules bool `json:"enable-owasp-modsecurity-crs"`
|
|
|
|
|
|
2019-05-15 12:34:00 +00:00
|
|
|
|
// ModSecuritySnippet adds custom rules to modsecurity section of nginx configuration
|
|
|
|
|
ModsecuritySnippet string `json:"modsecurity-snippet"`
|
|
|
|
|
|
2017-01-20 22:14:59 +00:00
|
|
|
|
// ClientHeaderBufferSize allows to configure a custom buffer
|
|
|
|
|
// size for reading client request header
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_buffer_size
|
|
|
|
|
ClientHeaderBufferSize string `json:"client-header-buffer-size"`
|
|
|
|
|
|
2017-08-24 12:30:12 +00:00
|
|
|
|
// Defines a timeout for reading client request header, in seconds
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_header_timeout
|
|
|
|
|
ClientHeaderTimeout int `json:"client-header-timeout,omitempty"`
|
|
|
|
|
|
2017-05-17 06:23:18 +00:00
|
|
|
|
// Sets buffer size for reading client request body
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_buffer_size
|
|
|
|
|
ClientBodyBufferSize string `json:"client-body-buffer-size,omitempty"`
|
|
|
|
|
|
2017-08-24 12:30:12 +00:00
|
|
|
|
// Defines a timeout for reading client request body, in seconds
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_timeout
|
|
|
|
|
ClientBodyTimeout int `json:"client-body-timeout,omitempty"`
|
|
|
|
|
|
2020-04-11 18:35:29 +00:00
|
|
|
|
// DisableAccessLog disables the Access Log globally for both HTTP and Stream contexts from NGINX ingress controller
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_log_module.html
|
2017-02-09 23:20:12 +00:00
|
|
|
|
DisableAccessLog bool `json:"disable-access-log,omitempty"`
|
|
|
|
|
|
2020-04-11 18:35:29 +00:00
|
|
|
|
// DisableHTTPAccessLog disables the Access Log for http context globally from NGINX ingress controller
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html
|
|
|
|
|
DisableHTTPAccessLog bool `json:"disable-http-access-log,omitempty"`
|
|
|
|
|
|
|
|
|
|
// DisableStreamAccessLog disables the Access Log for stream context globally from NGINX ingress controller
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_log_module.html
|
|
|
|
|
DisableStreamAccessLog bool `json:"disable-stream-access-log,omitempty"`
|
|
|
|
|
|
2018-02-02 19:53:28 +00:00
|
|
|
|
// DisableIpv6DNS disables IPv6 for nginx resolver
|
|
|
|
|
DisableIpv6DNS bool `json:"disable-ipv6-dns"`
|
|
|
|
|
|
2017-03-03 20:58:33 +00:00
|
|
|
|
// DisableIpv6 disable listening on ipv6 address
|
|
|
|
|
DisableIpv6 bool `json:"disable-ipv6,omitempty"`
|
|
|
|
|
|
2017-04-20 21:12:16 +00:00
|
|
|
|
// EnableUnderscoresInHeaders enables underscores in header names
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableUnderscoresInHeaders bool `json:"enable-underscores-in-headers"`
|
|
|
|
|
|
|
|
|
|
// IgnoreInvalidHeaders set if header fields with invalid names should be ignored
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers
|
|
|
|
|
// By default this is enabled
|
|
|
|
|
IgnoreInvalidHeaders bool `json:"ignore-invalid-headers"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// RetryNonIdempotent since 1.9.13 NGINX will not retry non-idempotent requests (POST, LOCK, PATCH)
|
|
|
|
|
// in case of an error. The previous behavior can be restored using the value true
|
2016-12-28 13:08:02 +00:00
|
|
|
|
RetryNonIdempotent bool `json:"retry-non-idempotent"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#error_log
|
|
|
|
|
// Configures logging level [debug | info | notice | warn | error | crit | alert | emerg]
|
|
|
|
|
// Log levels above are listed in the order of increasing severity
|
2016-12-28 13:08:02 +00:00
|
|
|
|
ErrorLogLevel string `json:"error-log-level,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-03-08 23:00:16 +00:00
|
|
|
|
// https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_field_size
|
|
|
|
|
// HTTP2MaxFieldSize Limits the maximum size of an HPACK-compressed request header field
|
|
|
|
|
HTTP2MaxFieldSize string `json:"http2-max-field-size,omitempty"`
|
|
|
|
|
|
|
|
|
|
// https://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_header_size
|
|
|
|
|
// HTTP2MaxHeaderSize Limits the maximum size of the entire request header list after HPACK decompression
|
|
|
|
|
HTTP2MaxHeaderSize string `json:"http2-max-header-size,omitempty"`
|
|
|
|
|
|
2018-09-03 05:53:30 +00:00
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_requests
|
|
|
|
|
// HTTP2MaxRequests Sets the maximum number of requests (including push requests) that can be served
|
|
|
|
|
// through one HTTP/2 connection, after which the next client request will lead to connection closing
|
|
|
|
|
// and the need of establishing a new connection.
|
|
|
|
|
HTTP2MaxRequests int `json:"http2-max-requests,omitempty"`
|
|
|
|
|
|
2019-10-31 12:13:38 +00:00
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_v2_module.html#http2_max_concurrent_streams
|
|
|
|
|
// Sets the maximum number of concurrent HTTP/2 streams in a connection.
|
|
|
|
|
HTTP2MaxConcurrentStreams int `json:"http2-max-concurrent-streams,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enables or disables the header HSTS in servers running SSL
|
2016-12-28 13:08:02 +00:00
|
|
|
|
HSTS bool `json:"hsts,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// Enables or disables the use of HSTS in all the subdomains of the servername
|
|
|
|
|
// Default: true
|
2016-12-28 13:08:02 +00:00
|
|
|
|
HSTSIncludeSubdomains bool `json:"hsts-include-subdomains,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// HTTP Strict Transport Security (often abbreviated as HSTS) is a security feature (HTTP header)
|
|
|
|
|
// that tell browsers that it should only be communicated with using HTTPS, instead of using HTTP.
|
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security
|
|
|
|
|
// max-age is the time, in seconds, that the browser should remember that this site is only to be
|
|
|
|
|
// accessed using HTTPS.
|
2016-12-28 13:08:02 +00:00
|
|
|
|
HSTSMaxAge string `json:"hsts-max-age,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-04-06 01:48:43 +00:00
|
|
|
|
// Enables or disables the preload attribute in HSTS feature
|
|
|
|
|
HSTSPreload bool `json:"hsts-preload,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Time during which a keep-alive client connection will stay open on the server side.
|
|
|
|
|
// The zero value disables keep-alive client connections
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
|
2016-12-28 13:08:02 +00:00
|
|
|
|
KeepAlive int `json:"keep-alive,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-05-17 06:23:18 +00:00
|
|
|
|
// Sets the maximum number of requests that can be served through one keep-alive connection.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_requests
|
|
|
|
|
KeepAliveRequests int `json:"keep-alive-requests,omitempty"`
|
|
|
|
|
|
2017-01-20 22:14:59 +00:00
|
|
|
|
// LargeClientHeaderBuffers Sets the maximum number and size of buffers used for reading
|
|
|
|
|
// large client request header.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers
|
|
|
|
|
// Default: 4 8k
|
|
|
|
|
LargeClientHeaderBuffers string `json:"large-client-header-buffers"`
|
|
|
|
|
|
Make log format json escaping configurable
This will allow json logging in nginx ingress controllers which greatly
improves ease of log indexing and searching via elasticsearch.
After this change is made, users could set the following property in the
ingress configmap to enable json logging:
log-format-upstream: '{"proxy_protocol_addr": "$proxy_protocol_addr", "proxy_add_x_forwarded_for": "$proxy_add_x_forwarded_for", "remote_user": "$remote_user", "time_iso8601": "$time_iso8601", "request": "$request", "status": "$status", "body_bytes_sent": "$body_bytes_sent", "http_referer": "$http_referer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "request_time": "$request_time", "proxy_upstream_name": "$proxy_upstream_name", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status": "$upstream_status"}'
2017-05-30 22:36:24 +00:00
|
|
|
|
// Enable json escaping
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
|
2017-06-15 03:05:04 +00:00
|
|
|
|
LogFormatEscapeJSON bool `json:"log-format-escape-json,omitempty"`
|
Make log format json escaping configurable
This will allow json logging in nginx ingress controllers which greatly
improves ease of log indexing and searching via elasticsearch.
After this change is made, users could set the following property in the
ingress configmap to enable json logging:
log-format-upstream: '{"proxy_protocol_addr": "$proxy_protocol_addr", "proxy_add_x_forwarded_for": "$proxy_add_x_forwarded_for", "remote_user": "$remote_user", "time_iso8601": "$time_iso8601", "request": "$request", "status": "$status", "body_bytes_sent": "$body_bytes_sent", "http_referer": "$http_referer", "http_user_agent": "$http_user_agent", "request_length": "$request_length", "request_time": "$request_time", "proxy_upstream_name": "$proxy_upstream_name", "upstream_addr": "$upstream_addr", "upstream_response_length": "$upstream_response_length", "upstream_response_time": "$upstream_response_time", "upstream_status": "$upstream_status"}'
2017-05-30 22:36:24 +00:00
|
|
|
|
|
2017-02-27 10:00:31 +00:00
|
|
|
|
// Customize upstream log_format
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
|
|
|
|
|
LogFormatUpstream string `json:"log-format-upstream,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Customize stream log_format
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
|
|
|
|
|
LogFormatStream string `json:"log-format-stream,omitempty"`
|
|
|
|
|
|
2018-08-04 15:53:56 +00:00
|
|
|
|
// If disabled, a worker process will accept one new connection at a time.
|
|
|
|
|
// Otherwise, a worker process will accept all new connections at a time.
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#multi_accept
|
|
|
|
|
// Default: true
|
|
|
|
|
EnableMultiAccept bool `json:"enable-multi-accept,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Maximum number of simultaneous connections that can be opened by each worker process
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#worker_connections
|
2016-12-28 13:08:02 +00:00
|
|
|
|
MaxWorkerConnections int `json:"max-worker-connections,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2018-12-27 16:24:09 +00:00
|
|
|
|
// Maximum number of files that can be opened by each worker process.
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#worker_rlimit_nofile
|
|
|
|
|
MaxWorkerOpenFiles int `json:"max-worker-open-files,omitempty"`
|
|
|
|
|
|
2016-10-14 18:20:34 +00:00
|
|
|
|
// Sets the bucket size for the map variables hash tables.
|
|
|
|
|
// Default value depends on the processor’s cache line size.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_map_module.html#map_hash_bucket_size
|
2016-12-28 13:08:02 +00:00
|
|
|
|
MapHashBucketSize int `json:"map-hash-bucket-size,omitempty"`
|
2016-10-14 18:20:34 +00:00
|
|
|
|
|
2018-03-28 12:27:34 +00:00
|
|
|
|
// NginxStatusIpv4Whitelist has the list of cidr that are allowed to access
|
|
|
|
|
// the /nginx_status endpoint of the "_" server
|
|
|
|
|
NginxStatusIpv4Whitelist []string `json:"nginx-status-ipv4-whitelist,omitempty"`
|
|
|
|
|
NginxStatusIpv6Whitelist []string `json:"nginx-status-ipv6-whitelist,omitempty"`
|
|
|
|
|
|
2020-04-06 16:02:13 +00:00
|
|
|
|
// Plugins configures plugins to use placed in the directory /etc/nginx/lua/plugins.
|
|
|
|
|
// Every plugin has to have main.lua in the root. Every plugin has to bundle all of its dependencies.
|
|
|
|
|
// The execution order follows the definition.
|
|
|
|
|
Plugins []string `json:"plugins,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// If UseProxyProtocol is enabled ProxyRealIPCIDR defines the default the IP/network address
|
|
|
|
|
// of your external load balancer
|
2017-06-28 14:53:08 +00:00
|
|
|
|
ProxyRealIPCIDR []string `json:"proxy-real-ip-cidr,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-02-07 18:13:08 +00:00
|
|
|
|
// Sets the name of the configmap that contains the headers to pass to the backend
|
|
|
|
|
ProxySetHeaders string `json:"proxy-set-headers,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Maximum size of the server names hash tables used in server names, map directive’s values,
|
|
|
|
|
// MIME types, names of request header strings, etcd.
|
|
|
|
|
// http://nginx.org/en/docs/hash.html
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#server_names_hash_max_size
|
2016-12-28 13:08:02 +00:00
|
|
|
|
ServerNameHashMaxSize int `json:"server-name-hash-max-size,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2016-08-26 22:30:56 +00:00
|
|
|
|
// Size of the bucket for the server names hash tables
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// http://nginx.org/en/docs/hash.html
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#server_names_hash_bucket_size
|
2016-12-28 13:08:02 +00:00
|
|
|
|
ServerNameHashBucketSize int `json:"server-name-hash-bucket-size,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-07-13 11:45:02 +00:00
|
|
|
|
// Size of the bucket for the proxy headers hash tables
|
|
|
|
|
// http://nginx.org/en/docs/hash.html
|
|
|
|
|
// https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_headers_hash_max_size
|
|
|
|
|
ProxyHeadersHashMaxSize int `json:"proxy-headers-hash-max-size,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Maximum size of the bucket for the proxy headers hash tables
|
|
|
|
|
// http://nginx.org/en/docs/hash.html
|
|
|
|
|
// https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_headers_hash_bucket_size
|
|
|
|
|
ProxyHeadersHashBucketSize int `json:"proxy-headers-hash-bucket-size,omitempty"`
|
|
|
|
|
|
2016-12-29 15:37:37 +00:00
|
|
|
|
// Enables or disables emitting nginx version in error messages and in the “Server” response header field.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens
|
2021-02-19 18:38:50 +00:00
|
|
|
|
// Default: false
|
2016-12-29 15:37:37 +00:00
|
|
|
|
ShowServerTokens bool `json:"server-tokens"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enabled ciphers list to enabled. The ciphers are specified in the format understood by
|
|
|
|
|
// the OpenSSL library
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ciphers
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLCiphers string `json:"ssl-ciphers,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-03-31 02:23:14 +00:00
|
|
|
|
// Specifies a curve for ECDHE ciphers.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ecdh_curve
|
|
|
|
|
SSLECDHCurve string `json:"ssl-ecdh-curve,omitempty"`
|
|
|
|
|
|
2017-03-08 13:41:55 +00:00
|
|
|
|
// The secret that contains Diffie-Hellman key to help with "Perfect Forward Secrecy"
|
2018-04-27 00:39:37 +00:00
|
|
|
|
// https://wiki.openssl.org/index.php/Diffie-Hellman_parameters
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// https://wiki.mozilla.org/Security/Server_Side_TLS#DHE_handshake_and_dhparam
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_dhparam
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLDHParam string `json:"ssl-dh-param,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// SSL enabled protocols to use
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_protocols
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLProtocols string `json:"ssl-protocols,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2019-08-07 20:04:09 +00:00
|
|
|
|
// Enables or disable TLS 1.3 early data.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_early_data
|
|
|
|
|
SSLEarlyData bool `json:"ssl-early-data,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enables or disables the use of shared SSL cache among worker processes.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_cache
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLSessionCache bool `json:"ssl-session-cache,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// Size of the SSL shared cache between all worker processes.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_cache
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLSessionCacheSize string `json:"ssl-session-cache-size,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// Enables or disables session resumption through TLS session tickets.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_tickets
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLSessionTickets bool `json:"ssl-session-tickets,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2017-10-08 22:37:19 +00:00
|
|
|
|
// Sets the secret key used to encrypt and decrypt TLS session tickets.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_tickets
|
|
|
|
|
// By default, a randomly generated key is used.
|
2018-07-15 22:24:16 +00:00
|
|
|
|
// Example: openssl rand 80 | openssl enc -A -base64
|
2017-10-08 22:37:19 +00:00
|
|
|
|
SSLSessionTicketKey string `json:"ssl-session-ticket-key,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Time during which a client may reuse the session parameters stored in a cache.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_timeout
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLSessionTimeout string `json:"ssl-session-timeout,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2016-11-10 22:56:29 +00:00
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_buffer_size
|
|
|
|
|
// Sets the size of the buffer used for sending data.
|
|
|
|
|
// 4k helps NGINX to improve TLS Time To First Byte (TTTFB)
|
|
|
|
|
// https://www.igvita.com/2013/12/16/optimizing-nginx-tls-time-to-first-byte/
|
2016-12-28 13:08:02 +00:00
|
|
|
|
SSLBufferSize string `json:"ssl-buffer-size,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2021-11-29 16:33:23 +00:00
|
|
|
|
// https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_reject_handshake
|
|
|
|
|
// If enabled, SSL handshakes to an invalid virtualhost will be rejected
|
|
|
|
|
// Default: false
|
|
|
|
|
SSLRejectHandshake bool `json:"ssl-reject-handshake"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enables or disables the use of the PROXY protocol to receive client connection
|
|
|
|
|
// (real IP address) information passed through proxy servers and load balancers
|
|
|
|
|
// such as HAproxy and Amazon Elastic Load Balancer (ELB).
|
|
|
|
|
// https://www.nginx.com/resources/admin-guide/proxy-protocol/
|
2016-12-28 13:08:02 +00:00
|
|
|
|
UseProxyProtocol bool `json:"use-proxy-protocol,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2018-06-04 01:10:41 +00:00
|
|
|
|
// When use-proxy-protocol is enabled, sets the maximum time the connection handler will wait
|
|
|
|
|
// to receive proxy headers.
|
|
|
|
|
// Example '60s'
|
|
|
|
|
ProxyProtocolHeaderTimeout time.Duration `json:"proxy-protocol-header-timeout,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enables or disables the use of the nginx module that compresses responses using the "gzip" method
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_gzip_module.html
|
2016-12-28 13:08:02 +00:00
|
|
|
|
UseGzip bool `json:"use-gzip,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2018-03-18 16:30:05 +00:00
|
|
|
|
// Enables or disables the use of the nginx geoip module that creates variables with values depending on the client IP
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_geoip_module.html
|
|
|
|
|
UseGeoIP bool `json:"use-geoip,omitempty"`
|
|
|
|
|
|
2018-10-29 20:25:23 +00:00
|
|
|
|
// UseGeoIP2 enables the geoip2 module for NGINX
|
|
|
|
|
// By default this is disabled
|
|
|
|
|
UseGeoIP2 bool `json:"use-geoip2,omitempty"`
|
|
|
|
|
|
2017-10-30 19:32:47 +00:00
|
|
|
|
// Enables or disables the use of the NGINX Brotli Module for compression
|
|
|
|
|
// https://github.com/google/ngx_brotli
|
2017-11-12 13:33:18 +00:00
|
|
|
|
EnableBrotli bool `json:"enable-brotli,omitempty"`
|
2017-10-30 19:32:47 +00:00
|
|
|
|
|
|
|
|
|
// Brotli Compression Level that will be used
|
|
|
|
|
BrotliLevel int `json:"brotli-level,omitempty"`
|
|
|
|
|
|
2021-11-02 11:52:59 +00:00
|
|
|
|
// Minimum length of responses, in bytes, that will be eligible for brotli compression
|
|
|
|
|
BrotliMinLength int `json:"brotli-min-length,omitempty"`
|
|
|
|
|
|
2017-10-30 19:32:47 +00:00
|
|
|
|
// MIME Types that will be compressed on-the-fly using Brotli module
|
|
|
|
|
BrotliTypes string `json:"brotli-types,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// Enables or disables the HTTP/2 support in secure connections
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_v2_module.html
|
|
|
|
|
// Default: true
|
2016-12-28 13:08:02 +00:00
|
|
|
|
UseHTTP2 bool `json:"use-http2,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
2018-07-09 00:30:59 +00:00
|
|
|
|
// gzip Compression Level that will be used
|
|
|
|
|
GzipLevel int `json:"gzip-level,omitempty"`
|
|
|
|
|
|
2020-02-14 06:23:36 +00:00
|
|
|
|
// Minimum length of responses to be sent to the client before it is eligible
|
|
|
|
|
// for gzip compression, in bytes.
|
|
|
|
|
GzipMinLength int `json:"gzip-min-length,omitempty"`
|
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
// MIME types in addition to "text/html" to compress. The special value “*” matches any MIME type.
|
|
|
|
|
// Responses with the “text/html” type are always compressed if UseGzip is enabled
|
2016-12-28 13:08:02 +00:00
|
|
|
|
GzipTypes string `json:"gzip-types,omitempty"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
|
|
|
|
|
// Defines the number of worker processes. By default auto means number of available CPU cores
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#worker_processes
|
2017-03-28 16:39:44 +00:00
|
|
|
|
WorkerProcesses string `json:"worker-processes,omitempty"`
|
2017-04-28 20:41:53 +00:00
|
|
|
|
|
2017-08-29 09:49:18 +00:00
|
|
|
|
// Defines a timeout for a graceful shutdown of worker processes
|
|
|
|
|
// http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout
|
|
|
|
|
WorkerShutdownTimeout string `json:"worker-shutdown-timeout,omitempty"`
|
|
|
|
|
|
2017-05-28 20:05:49 +00:00
|
|
|
|
// Sets the bucket size for the variables hash table.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_map_module.html#variables_hash_bucket_size
|
|
|
|
|
VariablesHashBucketSize int `json:"variables-hash-bucket-size,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Sets the maximum size of the variables hash table.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_map_module.html#variables_hash_max_size
|
|
|
|
|
VariablesHashMaxSize int `json:"variables-hash-max-size,omitempty"`
|
2017-06-22 03:39:06 +00:00
|
|
|
|
|
|
|
|
|
// Activates the cache for connections to upstream servers.
|
|
|
|
|
// The connections parameter sets the maximum number of idle keepalive connections to
|
|
|
|
|
// upstream servers that are preserved in the cache of each worker process. When this
|
|
|
|
|
// number is exceeded, the least recently used connections are closed.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
|
|
|
|
|
UpstreamKeepaliveConnections int `json:"upstream-keepalive-connections,omitempty"`
|
2017-07-06 23:13:32 +00:00
|
|
|
|
|
2018-10-10 23:56:07 +00:00
|
|
|
|
// Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_timeout
|
|
|
|
|
UpstreamKeepaliveTimeout int `json:"upstream-keepalive-timeout,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Sets the maximum number of requests that can be served through one keepalive connection.
|
|
|
|
|
// After the maximum number of requests is made, the connection is closed.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive_requests
|
|
|
|
|
UpstreamKeepaliveRequests int `json:"upstream-keepalive-requests,omitempty"`
|
|
|
|
|
|
2017-07-06 23:13:32 +00:00
|
|
|
|
// Sets the maximum size of the variables hash table.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_map_module.html#variables_hash_max_size
|
|
|
|
|
LimitConnZoneVariable string `json:"limit-conn-zone-variable,omitempty"`
|
2017-08-07 18:01:12 +00:00
|
|
|
|
|
|
|
|
|
// Sets the timeout between two successive read or write operations on client or proxied server connections.
|
|
|
|
|
// If no data is transmitted within this time, the connection is closed.
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout
|
|
|
|
|
ProxyStreamTimeout string `json:"proxy-stream-timeout,omitempty"`
|
2017-08-25 02:24:32 +00:00
|
|
|
|
|
2020-12-02 06:54:14 +00:00
|
|
|
|
// When a connection to the proxied server cannot be established, determines whether
|
|
|
|
|
// a client connection will be passed to the next server.
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream
|
|
|
|
|
ProxyStreamNextUpstream bool `json:"proxy-stream-next-upstream,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Limits the time allowed to pass a connection to the next server.
|
|
|
|
|
// The 0 value turns off this limitation.
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_timeout
|
|
|
|
|
ProxyStreamNextUpstreamTimeout string `json:"proxy-stream-next-upstream-timeout,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Limits the number of possible tries a request should be passed to the next server.
|
|
|
|
|
// The 0 value turns off this limitation.
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_tries
|
|
|
|
|
ProxyStreamNextUpstreamTries int `json:"proxy-stream-next-upstream-tries,omitempty"`
|
|
|
|
|
|
2017-11-30 20:53:23 +00:00
|
|
|
|
// Sets the number of datagrams expected from the proxied server in response
|
|
|
|
|
// to the client request if the UDP protocol is used.
|
|
|
|
|
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses
|
|
|
|
|
// Default: 1
|
|
|
|
|
ProxyStreamResponses int `json:"proxy-stream-responses,omitempty"`
|
|
|
|
|
|
2019-07-08 18:32:00 +00:00
|
|
|
|
// Modifies the HTTP version the proxy uses to interact with the backend.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version
|
|
|
|
|
ProxyHTTPVersion string `json:"proxy-http-version"`
|
|
|
|
|
|
2017-08-25 02:24:32 +00:00
|
|
|
|
// Sets the ipv4 addresses on which the server will accept requests.
|
|
|
|
|
BindAddressIpv4 []string `json:"bind-address-ipv4,omitempty"`
|
|
|
|
|
|
|
|
|
|
// Sets the ipv6 addresses on which the server will accept requests.
|
|
|
|
|
BindAddressIpv6 []string `json:"bind-address-ipv6,omitempty"`
|
2017-09-07 21:11:23 +00:00
|
|
|
|
|
2017-12-25 21:19:01 +00:00
|
|
|
|
// Sets whether to use incoming X-Forwarded headers.
|
|
|
|
|
UseForwardedHeaders bool `json:"use-forwarded-headers"`
|
|
|
|
|
|
2020-07-13 17:45:01 +00:00
|
|
|
|
// Sets whether to enable the real ip module
|
|
|
|
|
EnableRealIp bool `json:"enable-real-ip"`
|
|
|
|
|
|
2017-09-07 21:11:23 +00:00
|
|
|
|
// Sets the header field for identifying the originating IP address of a client
|
|
|
|
|
// Default is X-Forwarded-For
|
|
|
|
|
ForwardedForHeader string `json:"forwarded-for-header,omitempty"`
|
2017-09-17 21:44:01 +00:00
|
|
|
|
|
2017-10-09 09:10:58 +00:00
|
|
|
|
// Append the remote address to the X-Forwarded-For header instead of replacing it
|
|
|
|
|
// Default: false
|
|
|
|
|
ComputeFullForwardedFor bool `json:"compute-full-forwarded-for,omitempty"`
|
|
|
|
|
|
2018-05-21 07:32:50 +00:00
|
|
|
|
// If the request does not have a request-id, should we generate a random value?
|
|
|
|
|
// Default: true
|
2018-10-30 23:46:48 +00:00
|
|
|
|
GenerateRequestID bool `json:"generate-request-id,omitempty"`
|
2018-05-21 07:32:50 +00:00
|
|
|
|
|
2018-04-16 10:03:06 +00:00
|
|
|
|
// Adds an X-Original-Uri header with the original request URI to the backend request
|
|
|
|
|
// Default: true
|
2018-10-30 23:46:48 +00:00
|
|
|
|
ProxyAddOriginalURIHeader bool `json:"proxy-add-original-uri-header"`
|
2018-04-16 10:03:06 +00:00
|
|
|
|
|
2017-09-17 21:44:01 +00:00
|
|
|
|
// EnableOpentracing enables the nginx Opentracing extension
|
2018-10-10 03:25:53 +00:00
|
|
|
|
// https://github.com/opentracing-contrib/nginx-opentracing
|
2017-09-17 21:44:01 +00:00
|
|
|
|
// By default this is disabled
|
|
|
|
|
EnableOpentracing bool `json:"enable-opentracing"`
|
|
|
|
|
|
2019-05-25 13:12:27 +00:00
|
|
|
|
// OpentracingOperationName specifies a custom name for the server span
|
|
|
|
|
OpentracingOperationName string `json:"opentracing-operation-name"`
|
|
|
|
|
|
|
|
|
|
// OpentracingOperationName specifies a custom name for the location span
|
|
|
|
|
OpentracingLocationOperationName string `json:"opentracing-location-operation-name"`
|
|
|
|
|
|
2021-10-24 21:36:21 +00:00
|
|
|
|
// OpentracingTrustIncomingSpan sets whether or not to trust incoming trace spans
|
|
|
|
|
// If false, incoming span headers will be rejected
|
|
|
|
|
// Default: true
|
|
|
|
|
OpentracingTrustIncomingSpan bool `json:"opentracing-trust-incoming-span"`
|
|
|
|
|
|
2017-09-17 21:44:01 +00:00
|
|
|
|
// ZipkinCollectorHost specifies the host to use when uploading traces
|
|
|
|
|
ZipkinCollectorHost string `json:"zipkin-collector-host"`
|
|
|
|
|
|
|
|
|
|
// ZipkinCollectorPort specifies the port to use when uploading traces
|
2018-10-10 03:25:53 +00:00
|
|
|
|
// Default: 9411
|
2017-09-17 21:44:01 +00:00
|
|
|
|
ZipkinCollectorPort int `json:"zipkin-collector-port"`
|
|
|
|
|
|
|
|
|
|
// ZipkinServiceName specifies the service name to use for any traces created
|
|
|
|
|
// Default: nginx
|
|
|
|
|
ZipkinServiceName string `json:"zipkin-service-name"`
|
2017-10-01 14:45:33 +00:00
|
|
|
|
|
2018-06-28 14:42:32 +00:00
|
|
|
|
// ZipkinSampleRate specifies sampling rate for traces
|
|
|
|
|
// Default: 1.0
|
|
|
|
|
ZipkinSampleRate float32 `json:"zipkin-sample-rate"`
|
|
|
|
|
|
2018-01-17 21:28:59 +00:00
|
|
|
|
// JaegerCollectorHost specifies the host to use when uploading traces
|
|
|
|
|
JaegerCollectorHost string `json:"jaeger-collector-host"`
|
|
|
|
|
|
|
|
|
|
// JaegerCollectorPort specifies the port to use when uploading traces
|
2018-10-10 03:25:53 +00:00
|
|
|
|
// Default: 6831
|
2018-01-17 21:28:59 +00:00
|
|
|
|
JaegerCollectorPort int `json:"jaeger-collector-port"`
|
|
|
|
|
|
2021-02-18 19:40:04 +00:00
|
|
|
|
// JaegerEndpoint specifies the enpoint to use when uploading traces to a collector over TCP
|
|
|
|
|
JaegerEndpoint string `json:"jaeger-endpoint"`
|
|
|
|
|
|
2018-01-17 21:28:59 +00:00
|
|
|
|
// JaegerServiceName specifies the service name to use for any traces created
|
|
|
|
|
// Default: nginx
|
|
|
|
|
JaegerServiceName string `json:"jaeger-service-name"`
|
|
|
|
|
|
2021-03-23 23:43:34 +00:00
|
|
|
|
// JaegerPropagationFormat specifies the traceparent/tracestate propagation format
|
|
|
|
|
JaegerPropagationFormat string `json:"jaeger-propagation-format"`
|
|
|
|
|
|
2018-01-17 21:28:59 +00:00
|
|
|
|
// JaegerSamplerType specifies the sampler to be used when sampling traces.
|
|
|
|
|
// The available samplers are: const, probabilistic, ratelimiting, remote
|
|
|
|
|
// Default: const
|
|
|
|
|
JaegerSamplerType string `json:"jaeger-sampler-type"`
|
|
|
|
|
|
|
|
|
|
// JaegerSamplerParam specifies the argument to be passed to the sampler constructor
|
|
|
|
|
// Default: 1
|
|
|
|
|
JaegerSamplerParam string `json:"jaeger-sampler-param"`
|
|
|
|
|
|
2019-05-21 03:06:41 +00:00
|
|
|
|
// JaegerSamplerHost specifies the host used for remote sampling consultation
|
|
|
|
|
// Default: http://127.0.0.1
|
|
|
|
|
JaegerSamplerHost string `json:"jaeger-sampler-host"`
|
|
|
|
|
|
|
|
|
|
// JaegerSamplerHost specifies the host used for remote sampling consultation
|
|
|
|
|
// Default: 5778
|
|
|
|
|
JaegerSamplerPort int `json:"jaeger-sampler-port"`
|
|
|
|
|
|
2019-09-17 09:35:53 +00:00
|
|
|
|
// JaegerTraceContextHeaderName specifies the header name used for passing trace context
|
|
|
|
|
// Default: uber-trace-id
|
|
|
|
|
JaegerTraceContextHeaderName string `json:"jaeger-trace-context-header-name"`
|
|
|
|
|
|
|
|
|
|
// JaegerDebugHeader specifies the header name used for force sampling
|
|
|
|
|
// Default: jaeger-debug-id
|
|
|
|
|
JaegerDebugHeader string `json:"jaeger-debug-header"`
|
|
|
|
|
|
|
|
|
|
// JaegerBaggageHeader specifies the header name used to submit baggage if there is no root span
|
|
|
|
|
// Default: jaeger-baggage
|
|
|
|
|
JaegerBaggageHeader string `json:"jaeger-baggage-header"`
|
|
|
|
|
|
|
|
|
|
// TraceBaggageHeaderPrefix specifies the header prefix used to propagate baggage
|
|
|
|
|
// Default: uberctx-
|
|
|
|
|
JaegerTraceBaggageHeaderPrefix string `json:"jaeger-tracer-baggage-header-prefix"`
|
|
|
|
|
|
2019-02-15 20:20:10 +00:00
|
|
|
|
// DatadogCollectorHost specifies the datadog agent host to use when uploading traces
|
|
|
|
|
DatadogCollectorHost string `json:"datadog-collector-host"`
|
|
|
|
|
|
|
|
|
|
// DatadogCollectorPort specifies the port to use when uploading traces
|
|
|
|
|
// Default: 8126
|
|
|
|
|
DatadogCollectorPort int `json:"datadog-collector-port"`
|
|
|
|
|
|
2020-10-01 21:42:22 +00:00
|
|
|
|
// DatadogEnvironment specifies the environment this trace belongs to.
|
|
|
|
|
// Default: prod
|
|
|
|
|
DatadogEnvironment string `json:"datadog-environment"`
|
|
|
|
|
|
2019-02-15 20:20:10 +00:00
|
|
|
|
// DatadogServiceName specifies the service name to use for any traces created
|
|
|
|
|
// Default: nginx
|
|
|
|
|
DatadogServiceName string `json:"datadog-service-name"`
|
|
|
|
|
|
|
|
|
|
// DatadogOperationNameOverride overrides the operation naem to use for any traces crated
|
|
|
|
|
// Default: nginx.handle
|
|
|
|
|
DatadogOperationNameOverride string `json:"datadog-operation-name-override"`
|
|
|
|
|
|
2020-01-08 00:59:59 +00:00
|
|
|
|
// DatadogPrioritySampling specifies to use client-side sampling
|
|
|
|
|
// If true disables client-side sampling (thus ignoring sample_rate) and enables distributed
|
|
|
|
|
// priority sampling, where traces are sampled based on a combination of user-assigned
|
|
|
|
|
// Default: true
|
|
|
|
|
DatadogPrioritySampling bool `json:"datadog-priority-sampling"`
|
|
|
|
|
|
|
|
|
|
// DatadogSampleRate specifies sample rate for any traces created.
|
|
|
|
|
// This is effective only when datadog-priority-sampling is false
|
|
|
|
|
// Default: 1.0
|
|
|
|
|
DatadogSampleRate float32 `json:"datadog-sample-rate"`
|
|
|
|
|
|
2018-08-03 18:11:25 +00:00
|
|
|
|
// MainSnippet adds custom configuration to the main section of the nginx configuration
|
|
|
|
|
MainSnippet string `json:"main-snippet"`
|
|
|
|
|
|
2017-10-01 14:45:33 +00:00
|
|
|
|
// HTTPSnippet adds custom configuration to the http section of the nginx configuration
|
|
|
|
|
HTTPSnippet string `json:"http-snippet"`
|
|
|
|
|
|
|
|
|
|
// ServerSnippet adds custom configuration to all the servers in the nginx configuration
|
|
|
|
|
ServerSnippet string `json:"server-snippet"`
|
|
|
|
|
|
2021-12-23 19:46:30 +00:00
|
|
|
|
// StreamSnippet adds custom configuration to the stream section of the nginx configuration
|
|
|
|
|
StreamSnippet string `json:"stream-snippet"`
|
|
|
|
|
|
2017-10-01 14:45:33 +00:00
|
|
|
|
// LocationSnippet adds custom configuration to all the locations in the nginx configuration
|
|
|
|
|
LocationSnippet string `json:"location-snippet"`
|
2017-11-30 14:59:39 +00:00
|
|
|
|
|
|
|
|
|
// HTTPRedirectCode sets the HTTP status code to be used in redirects.
|
|
|
|
|
// Supported codes are 301,302,307 and 308
|
|
|
|
|
// Default: 308
|
|
|
|
|
HTTPRedirectCode int `json:"http-redirect-code"`
|
2018-01-17 23:12:46 +00:00
|
|
|
|
|
|
|
|
|
// ReusePort instructs NGINX to create an individual listening socket for
|
|
|
|
|
// each worker process (using the SO_REUSEPORT socket option), allowing a
|
|
|
|
|
// kernel to distribute incoming connections between worker processes
|
2018-08-04 21:43:34 +00:00
|
|
|
|
// Default: true
|
2018-01-17 23:12:46 +00:00
|
|
|
|
ReusePort bool `json:"reuse-port"`
|
2018-01-18 18:37:22 +00:00
|
|
|
|
|
|
|
|
|
// HideHeaders sets additional header that will not be passed from the upstream
|
|
|
|
|
// server to the client response
|
|
|
|
|
// Default: empty
|
|
|
|
|
HideHeaders []string `json:"hide-headers"`
|
2018-01-30 13:24:44 +00:00
|
|
|
|
|
|
|
|
|
// LimitReqStatusCode Sets the status code to return in response to rejected requests.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req_status
|
|
|
|
|
// Default: 503
|
|
|
|
|
LimitReqStatusCode int `json:"limit-req-status-code"`
|
2018-02-25 15:47:14 +00:00
|
|
|
|
|
2019-01-09 14:41:58 +00:00
|
|
|
|
// LimitConnStatusCode Sets the status code to return in response to rejected connections.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html#limit_conn_status
|
|
|
|
|
// Default: 503
|
|
|
|
|
LimitConnStatusCode int `json:"limit-conn-status-code"`
|
|
|
|
|
|
2018-02-25 15:47:14 +00:00
|
|
|
|
// EnableSyslog enables the configuration for remote logging in NGINX
|
|
|
|
|
EnableSyslog bool `json:"enable-syslog"`
|
|
|
|
|
// SyslogHost FQDN or IP address where the logs should be sent
|
|
|
|
|
SyslogHost string `json:"syslog-host"`
|
|
|
|
|
// SyslogPort port
|
2018-03-23 12:12:26 +00:00
|
|
|
|
SyslogPort int `json:"syslog-port"`
|
2018-03-18 20:44:59 +00:00
|
|
|
|
|
|
|
|
|
// NoTLSRedirectLocations is a comma-separated list of locations
|
|
|
|
|
// that should not get redirected to TLS
|
|
|
|
|
NoTLSRedirectLocations string `json:"no-tls-redirect-locations"`
|
2018-04-02 00:02:34 +00:00
|
|
|
|
|
|
|
|
|
// NoAuthLocations is a comma-separated list of locations that
|
|
|
|
|
// should not get authenticated
|
|
|
|
|
NoAuthLocations string `json:"no-auth-locations"`
|
2018-04-08 20:37:13 +00:00
|
|
|
|
|
2018-11-27 16:12:17 +00:00
|
|
|
|
// GlobalExternalAuth indicates the access to all locations requires
|
|
|
|
|
// authentication using an external provider
|
|
|
|
|
// +optional
|
|
|
|
|
GlobalExternalAuth GlobalExternalAuth `json:"global-external-auth"`
|
|
|
|
|
|
2018-06-21 14:50:57 +00:00
|
|
|
|
// Checksum contains a checksum of the configmap configuration
|
|
|
|
|
Checksum string `json:"-"`
|
2018-08-27 13:50:04 +00:00
|
|
|
|
|
|
|
|
|
// Block all requests from given IPs
|
|
|
|
|
BlockCIDRs []string `json:"block-cidrs"`
|
|
|
|
|
|
|
|
|
|
// Block all requests with given User-Agent headers
|
|
|
|
|
BlockUserAgents []string `json:"block-user-agents"`
|
|
|
|
|
|
|
|
|
|
// Block all requests with given Referer headers
|
|
|
|
|
BlockReferers []string `json:"block-referers"`
|
2019-08-06 11:21:59 +00:00
|
|
|
|
|
|
|
|
|
// Lua shared dict configuration data / certificate data
|
|
|
|
|
LuaSharedDicts map[string]int `json:"lua-shared-dicts"`
|
2019-08-13 21:14:55 +00:00
|
|
|
|
|
|
|
|
|
// DefaultSSLCertificate holds the default SSL certificate to use in the configuration
|
|
|
|
|
// It can be the fake certificate or the one behind the flag --default-ssl-certificate
|
|
|
|
|
DefaultSSLCertificate *ingress.SSLCert `json:"-"`
|
2020-01-29 08:46:18 +00:00
|
|
|
|
|
|
|
|
|
// ProxySSLLocationOnly controls whether the proxy-ssl parameters defined in the
|
|
|
|
|
// proxy-ssl-* annotations are applied on on location level only in the nginx.conf file
|
|
|
|
|
// Default is that those are applied on server level, too
|
|
|
|
|
ProxySSLLocationOnly bool `json:"proxy-ssl-location-only"`
|
2020-06-21 03:10:51 +00:00
|
|
|
|
|
|
|
|
|
// DefaultType Sets the default MIME type of a response.
|
|
|
|
|
// http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type
|
|
|
|
|
// Default: text/html
|
|
|
|
|
DefaultType string `json:"default-type"`
|
2020-12-24 16:39:12 +00:00
|
|
|
|
|
|
|
|
|
// GlobalRateLimitMemcachedHost configures memcached host.
|
|
|
|
|
GlobalRateLimitMemcachedHost string `json:"global-rate-limit-memcached-host"`
|
|
|
|
|
|
|
|
|
|
// GlobalRateLimitMemcachedPort configures memcached port.
|
|
|
|
|
GlobalRateLimitMemcachedPort int `json:"global-rate-limit-memcached-port"`
|
|
|
|
|
|
|
|
|
|
// GlobalRateLimitMemcachedConnectTimeout configures timeout when connecting to memcached.
|
|
|
|
|
// The unit is millisecond.
|
|
|
|
|
GlobalRateLimitMemcachedConnectTimeout int `json:"global-rate-limit-memcached-connect-timeout"`
|
|
|
|
|
|
|
|
|
|
// GlobalRateLimitMemcachedMaxIdleTimeout configured how long connections
|
|
|
|
|
// should be kept alive in idle state. The unit is millisecond.
|
|
|
|
|
GlobalRateLimitMemcachedMaxIdleTimeout int `json:"global-rate-limit-memcached-max-idle-timeout"`
|
|
|
|
|
|
|
|
|
|
// GlobalRateLimitMemcachedPoolSize configures how many connections
|
|
|
|
|
// should be kept alive in the pool.
|
|
|
|
|
// Note that this is per NGINX worker. Make sure your memcached server can
|
|
|
|
|
// handle `MemcachedPoolSize * <nginx worker count> * <nginx replica count>`
|
|
|
|
|
// simultaneous connections.
|
|
|
|
|
GlobalRateLimitMemcachedPoolSize int `json:"global-rate-limit-memcached-pool-size"`
|
|
|
|
|
|
|
|
|
|
// GlobalRateLimitStatucCode determines the HTTP status code to return
|
|
|
|
|
// when limit is exceeding during global rate limiting.
|
|
|
|
|
GlobalRateLimitStatucCode int `json:"global-rate-limit-status-code"`
|
2016-06-05 13:36:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 18:24:26 +00:00
|
|
|
|
// NewDefault returns the default nginx configuration
|
2016-06-05 13:36:00 +00:00
|
|
|
|
func NewDefault() Configuration {
|
2017-07-06 20:17:46 +00:00
|
|
|
|
defIPCIDR := make([]string, 0)
|
2017-08-25 02:24:32 +00:00
|
|
|
|
defBindAddress := make([]string, 0)
|
2018-08-27 13:50:04 +00:00
|
|
|
|
defBlockEntity := make([]string, 0)
|
2018-03-28 12:27:34 +00:00
|
|
|
|
defNginxStatusIpv4Whitelist := make([]string, 0)
|
|
|
|
|
defNginxStatusIpv6Whitelist := make([]string, 0)
|
2018-11-27 16:12:17 +00:00
|
|
|
|
defResponseHeaders := make([]string, 0)
|
2018-03-28 12:27:34 +00:00
|
|
|
|
defIPCIDR = append(defIPCIDR, "0.0.0.0/0")
|
|
|
|
|
defNginxStatusIpv4Whitelist = append(defNginxStatusIpv4Whitelist, "127.0.0.1")
|
|
|
|
|
defNginxStatusIpv6Whitelist = append(defNginxStatusIpv6Whitelist, "::1")
|
2018-06-04 01:10:41 +00:00
|
|
|
|
defProxyDeadlineDuration := time.Duration(5) * time.Second
|
2020-08-18 09:03:38 +00:00
|
|
|
|
defGlobalExternalAuth := GlobalExternalAuth{"", "", "", "", "", append(defResponseHeaders, ""), "", "", "", []string{}, map[string]string{}}
|
2018-03-28 12:27:34 +00:00
|
|
|
|
|
2016-06-05 13:36:00 +00:00
|
|
|
|
cfg := Configuration{
|
2021-09-20 23:52:23 +00:00
|
|
|
|
|
|
|
|
|
AllowSnippetAnnotations: true,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
AllowBackendServerHeader: false,
|
2021-11-23 17:06:17 +00:00
|
|
|
|
AnnotationValueWordBlocklist: "",
|
2019-02-19 23:02:01 +00:00
|
|
|
|
AccessLogPath: "/var/log/nginx/access.log",
|
|
|
|
|
AccessLogParams: "",
|
|
|
|
|
EnableAccessLogForDefaultBackend: false,
|
|
|
|
|
WorkerCPUAffinity: "",
|
|
|
|
|
ErrorLogPath: "/var/log/nginx/error.log",
|
|
|
|
|
BlockCIDRs: defBlockEntity,
|
|
|
|
|
BlockUserAgents: defBlockEntity,
|
|
|
|
|
BlockReferers: defBlockEntity,
|
|
|
|
|
BrotliLevel: 4,
|
2021-11-02 11:52:59 +00:00
|
|
|
|
BrotliMinLength: 20,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
BrotliTypes: brotliTypes,
|
|
|
|
|
ClientHeaderBufferSize: "1k",
|
|
|
|
|
ClientHeaderTimeout: 60,
|
|
|
|
|
ClientBodyBufferSize: "8k",
|
|
|
|
|
ClientBodyTimeout: 60,
|
|
|
|
|
EnableUnderscoresInHeaders: false,
|
|
|
|
|
ErrorLogLevel: errorLevel,
|
|
|
|
|
UseForwardedHeaders: false,
|
2020-07-13 17:45:01 +00:00
|
|
|
|
EnableRealIp: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
ForwardedForHeader: "X-Forwarded-For",
|
|
|
|
|
ComputeFullForwardedFor: false,
|
2019-09-25 13:31:16 +00:00
|
|
|
|
ProxyAddOriginalURIHeader: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
GenerateRequestID: true,
|
|
|
|
|
HTTP2MaxFieldSize: "4k",
|
|
|
|
|
HTTP2MaxHeaderSize: "16k",
|
|
|
|
|
HTTP2MaxRequests: 1000,
|
2019-10-31 12:13:38 +00:00
|
|
|
|
HTTP2MaxConcurrentStreams: 128,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
HTTPRedirectCode: 308,
|
|
|
|
|
HSTS: true,
|
|
|
|
|
HSTSIncludeSubdomains: true,
|
|
|
|
|
HSTSMaxAge: hstsMaxAge,
|
|
|
|
|
HSTSPreload: false,
|
|
|
|
|
IgnoreInvalidHeaders: true,
|
2020-09-08 19:26:40 +00:00
|
|
|
|
GzipLevel: 1,
|
2020-02-14 06:23:36 +00:00
|
|
|
|
GzipMinLength: 256,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
GzipTypes: gzipTypes,
|
|
|
|
|
KeepAlive: 75,
|
|
|
|
|
KeepAliveRequests: 100,
|
|
|
|
|
LargeClientHeaderBuffers: "4 8k",
|
|
|
|
|
LogFormatEscapeJSON: false,
|
|
|
|
|
LogFormatStream: logFormatStream,
|
|
|
|
|
LogFormatUpstream: logFormatUpstream,
|
|
|
|
|
EnableMultiAccept: true,
|
|
|
|
|
MaxWorkerConnections: 16384,
|
|
|
|
|
MaxWorkerOpenFiles: 0,
|
|
|
|
|
MapHashBucketSize: 64,
|
|
|
|
|
NginxStatusIpv4Whitelist: defNginxStatusIpv4Whitelist,
|
|
|
|
|
NginxStatusIpv6Whitelist: defNginxStatusIpv6Whitelist,
|
|
|
|
|
ProxyRealIPCIDR: defIPCIDR,
|
|
|
|
|
ProxyProtocolHeaderTimeout: defProxyDeadlineDuration,
|
|
|
|
|
ServerNameHashMaxSize: 1024,
|
|
|
|
|
ProxyHeadersHashMaxSize: 512,
|
|
|
|
|
ProxyHeadersHashBucketSize: 64,
|
|
|
|
|
ProxyStreamResponses: 1,
|
|
|
|
|
ReusePort: true,
|
2020-09-17 11:19:32 +00:00
|
|
|
|
ShowServerTokens: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
SSLBufferSize: sslBufferSize,
|
|
|
|
|
SSLCiphers: sslCiphers,
|
|
|
|
|
SSLECDHCurve: "auto",
|
|
|
|
|
SSLProtocols: sslProtocols,
|
2019-08-07 20:04:09 +00:00
|
|
|
|
SSLEarlyData: sslEarlyData,
|
2021-11-29 16:33:23 +00:00
|
|
|
|
SSLRejectHandshake: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
SSLSessionCache: true,
|
|
|
|
|
SSLSessionCacheSize: sslSessionCacheSize,
|
2020-09-18 04:08:00 +00:00
|
|
|
|
SSLSessionTickets: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
SSLSessionTimeout: sslSessionTimeout,
|
|
|
|
|
EnableBrotli: false,
|
2020-09-25 00:01:55 +00:00
|
|
|
|
UseGzip: false,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
UseGeoIP: true,
|
|
|
|
|
UseGeoIP2: false,
|
|
|
|
|
WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
|
2019-09-27 13:23:12 +00:00
|
|
|
|
WorkerShutdownTimeout: "240s",
|
2020-02-21 19:01:33 +00:00
|
|
|
|
VariablesHashBucketSize: 256,
|
2019-02-19 23:02:01 +00:00
|
|
|
|
VariablesHashMaxSize: 2048,
|
|
|
|
|
UseHTTP2: true,
|
|
|
|
|
ProxyStreamTimeout: "600s",
|
2020-12-02 06:54:14 +00:00
|
|
|
|
ProxyStreamNextUpstream: true,
|
|
|
|
|
ProxyStreamNextUpstreamTimeout: "600s",
|
|
|
|
|
ProxyStreamNextUpstreamTries: 3,
|
2016-11-10 22:56:29 +00:00
|
|
|
|
Backend: defaults.Backend{
|
2019-04-15 15:08:57 +00:00
|
|
|
|
ProxyBodySize: bodySize,
|
|
|
|
|
ProxyConnectTimeout: 5,
|
|
|
|
|
ProxyReadTimeout: 60,
|
|
|
|
|
ProxySendTimeout: 60,
|
|
|
|
|
ProxyBuffersNumber: 4,
|
|
|
|
|
ProxyBufferSize: "4k",
|
|
|
|
|
ProxyCookieDomain: "off",
|
|
|
|
|
ProxyCookiePath: "off",
|
|
|
|
|
ProxyNextUpstream: "error timeout",
|
|
|
|
|
ProxyNextUpstreamTimeout: 0,
|
|
|
|
|
ProxyNextUpstreamTries: 3,
|
|
|
|
|
ProxyRequestBuffering: "on",
|
|
|
|
|
ProxyRedirectFrom: "off",
|
|
|
|
|
ProxyRedirectTo: "off",
|
2021-05-23 15:51:38 +00:00
|
|
|
|
PreserveTrailingSlash: false,
|
2019-04-15 15:08:57 +00:00
|
|
|
|
SSLRedirect: true,
|
|
|
|
|
CustomHTTPErrors: []int{},
|
|
|
|
|
WhitelistSourceRange: []string{},
|
|
|
|
|
SkipAccessLogURLs: []string{},
|
|
|
|
|
LimitRate: 0,
|
|
|
|
|
LimitRateAfter: 0,
|
|
|
|
|
ProxyBuffering: "off",
|
2019-07-08 18:32:00 +00:00
|
|
|
|
ProxyHTTPVersion: "1.1",
|
2019-08-12 17:27:05 +00:00
|
|
|
|
ProxyMaxTempFileSize: "1024m",
|
2021-09-07 19:47:15 +00:00
|
|
|
|
ServiceUpstream: false,
|
2016-11-10 22:56:29 +00:00
|
|
|
|
},
|
2020-12-24 16:39:12 +00:00
|
|
|
|
UpstreamKeepaliveConnections: 320,
|
|
|
|
|
UpstreamKeepaliveTimeout: 60,
|
|
|
|
|
UpstreamKeepaliveRequests: 10000,
|
|
|
|
|
LimitConnZoneVariable: defaultLimitConnZoneVariable,
|
|
|
|
|
BindAddressIpv4: defBindAddress,
|
|
|
|
|
BindAddressIpv6: defBindAddress,
|
2021-10-24 21:36:21 +00:00
|
|
|
|
OpentracingTrustIncomingSpan: true,
|
2020-12-24 16:39:12 +00:00
|
|
|
|
ZipkinCollectorPort: 9411,
|
|
|
|
|
ZipkinServiceName: "nginx",
|
|
|
|
|
ZipkinSampleRate: 1.0,
|
|
|
|
|
JaegerCollectorPort: 6831,
|
2021-03-23 23:43:34 +00:00
|
|
|
|
JaegerPropagationFormat: "jaeger",
|
2020-12-24 16:39:12 +00:00
|
|
|
|
JaegerServiceName: "nginx",
|
|
|
|
|
JaegerSamplerType: "const",
|
|
|
|
|
JaegerSamplerParam: "1",
|
|
|
|
|
JaegerSamplerPort: 5778,
|
|
|
|
|
JaegerSamplerHost: "http://127.0.0.1",
|
|
|
|
|
DatadogServiceName: "nginx",
|
|
|
|
|
DatadogEnvironment: "prod",
|
|
|
|
|
DatadogCollectorPort: 8126,
|
|
|
|
|
DatadogOperationNameOverride: "nginx.handle",
|
|
|
|
|
DatadogSampleRate: 1.0,
|
|
|
|
|
DatadogPrioritySampling: true,
|
|
|
|
|
LimitReqStatusCode: 503,
|
|
|
|
|
LimitConnStatusCode: 503,
|
|
|
|
|
SyslogPort: 514,
|
|
|
|
|
NoTLSRedirectLocations: "/.well-known/acme-challenge",
|
|
|
|
|
NoAuthLocations: "/.well-known/acme-challenge",
|
|
|
|
|
GlobalExternalAuth: defGlobalExternalAuth,
|
|
|
|
|
ProxySSLLocationOnly: false,
|
|
|
|
|
DefaultType: "text/html",
|
|
|
|
|
GlobalRateLimitMemcachedPort: 11211,
|
|
|
|
|
GlobalRateLimitMemcachedConnectTimeout: 50,
|
|
|
|
|
GlobalRateLimitMemcachedMaxIdleTimeout: 10000,
|
|
|
|
|
GlobalRateLimitMemcachedPoolSize: 50,
|
|
|
|
|
GlobalRateLimitStatucCode: 429,
|
2016-06-05 13:36:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-08 23:31:02 +00:00
|
|
|
|
if klog.V(5).Enabled() {
|
2016-06-05 13:36:00 +00:00
|
|
|
|
cfg.ErrorLogLevel = "debug"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return cfg
|
|
|
|
|
}
|
2016-11-16 18:24:26 +00:00
|
|
|
|
|
2017-01-19 02:31:33 +00:00
|
|
|
|
// TemplateConfig contains the nginx configuration to render the file nginx.conf
|
2016-11-16 18:24:26 +00:00
|
|
|
|
type TemplateConfig struct {
|
2019-08-13 21:14:55 +00:00
|
|
|
|
ProxySetHeaders map[string]string
|
|
|
|
|
AddHeaders map[string]string
|
|
|
|
|
BacklogSize int
|
|
|
|
|
Backends []*ingress.Backend
|
|
|
|
|
PassthroughBackends []*ingress.SSLPassthroughBackend
|
|
|
|
|
Servers []*ingress.Server
|
|
|
|
|
TCPBackends []ingress.L4Service
|
|
|
|
|
UDPBackends []ingress.L4Service
|
|
|
|
|
HealthzURI string
|
|
|
|
|
Cfg Configuration
|
|
|
|
|
IsIPV6Enabled bool
|
|
|
|
|
IsSSLPassthroughEnabled bool
|
|
|
|
|
NginxStatusIpv4Whitelist []string
|
|
|
|
|
NginxStatusIpv6Whitelist []string
|
|
|
|
|
RedirectServers interface{}
|
|
|
|
|
ListenPorts *ListenPorts
|
|
|
|
|
PublishService *apiv1.Service
|
|
|
|
|
EnableMetrics bool
|
2021-07-09 00:16:53 +00:00
|
|
|
|
MaxmindEditionFiles *[]string
|
2020-06-20 06:58:14 +00:00
|
|
|
|
MonitorMaxBatchSize int
|
2022-04-09 04:48:04 +00:00
|
|
|
|
PID string
|
|
|
|
|
StatusPath string
|
|
|
|
|
StatusPort int
|
|
|
|
|
StreamPort int
|
|
|
|
|
StreamSnippets []string
|
2017-08-24 13:33:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListenPorts describe the ports required to run the
|
|
|
|
|
// NGINX Ingress controller
|
|
|
|
|
type ListenPorts struct {
|
|
|
|
|
HTTP int
|
|
|
|
|
HTTPS int
|
|
|
|
|
Health int
|
|
|
|
|
Default int
|
|
|
|
|
SSLProxy int
|
2016-11-16 18:24:26 +00:00
|
|
|
|
}
|
2018-11-27 16:12:17 +00:00
|
|
|
|
|
|
|
|
|
// GlobalExternalAuth describe external authentication configuration for the
|
|
|
|
|
// NGINX Ingress controller
|
|
|
|
|
type GlobalExternalAuth struct {
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
// Host contains the hostname defined in the URL
|
2020-08-18 09:03:38 +00:00
|
|
|
|
Host string `json:"host"`
|
|
|
|
|
SigninURL string `json:"signinUrl"`
|
|
|
|
|
SigninURLRedirectParam string `json:"signinUrlRedirectParam"`
|
|
|
|
|
Method string `json:"method"`
|
|
|
|
|
ResponseHeaders []string `json:"responseHeaders,omitempty"`
|
|
|
|
|
RequestRedirect string `json:"requestRedirect"`
|
|
|
|
|
AuthSnippet string `json:"authSnippet"`
|
|
|
|
|
AuthCacheKey string `json:"authCacheKey"`
|
|
|
|
|
AuthCacheDuration []string `json:"authCacheDuration"`
|
|
|
|
|
ProxySetHeaders map[string]string `json:"proxySetHeaders,omitempty"`
|
2018-11-27 16:12:17 +00:00
|
|
|
|
}
|