diff --git a/docs/user-guide/nginx-configuration/configmap.md b/docs/user-guide/nginx-configuration/configmap.md index 0d2cde7f9..54af839e1 100755 --- a/docs/user-guide/nginx-configuration/configmap.md +++ b/docs/user-guide/nginx-configuration/configmap.md @@ -112,6 +112,9 @@ The following table shows a configuration option's name, type, and the default v |[upstream-keepalive-requests](#upstream-keepalive-requests)|int|10000| |[limit-conn-zone-variable](#limit-conn-zone-variable)|string|"$binary_remote_addr"| |[proxy-stream-timeout](#proxy-stream-timeout)|string|"600s"| +|[proxy-stream-next-upstream](#proxy-stream-next-upstream)|bool|"true"| +|[proxy-stream-next-upstream-timeout](#proxy-stream-next-upstream-timeout)|string|"600s"| +|[proxy-stream-next-upstream-tries](#proxy-stream-next-upstream-tries)|int|3| |[proxy-stream-responses](#proxy-stream-responses)|int|1| |[bind-address](#bind-address)|[]string|""| |[use-forwarded-headers](#use-forwarded-headers)|bool|"false"| @@ -733,6 +736,27 @@ Sets the timeout between two successive read or write operations on client or pr _References:_ [http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout](http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout) +## proxy-stream-next-upstream + +When a connection to the proxied server cannot be established, determines whether a client connection will be passed to the next server. + +_References:_ +[http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream](http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream) + +## proxy-stream-next-upstream-timeout + +Limits the time allowed to pass a connection to the next server. The 0 value turns off this limitation. + +_References:_ +[http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_timeout](http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_timeout) + +## proxy-stream-next-upstream-tries + +Limits the number of possible tries a request should be passed to the next server. The 0 value turns off this limitation. + +_References:_ +[http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_tries](http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_next_upstream_timeout) + ## proxy-stream-responses Sets the number of datagrams expected from the proxied server in response to the client request if the UDP protocol is used. diff --git a/internal/ingress/controller/config/config.go b/internal/ingress/controller/config/config.go index 454822342..b8c51bdb7 100644 --- a/internal/ingress/controller/config/config.go +++ b/internal/ingress/controller/config/config.go @@ -469,6 +469,21 @@ type Configuration struct { // http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout ProxyStreamTimeout string `json:"proxy-stream-timeout,omitempty"` + // 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"` + // 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 @@ -786,6 +801,9 @@ func NewDefault() Configuration { VariablesHashMaxSize: 2048, UseHTTP2: true, ProxyStreamTimeout: "600s", + ProxyStreamNextUpstream: true, + ProxyStreamNextUpstreamTimeout: "600s", + ProxyStreamNextUpstreamTries: 3, Backend: defaults.Backend{ ProxyBodySize: bodySize, ProxyConnectTimeout: 5, diff --git a/rootfs/etc/nginx/template/nginx.tmpl b/rootfs/etc/nginx/template/nginx.tmpl index 24b6aefd5..c283ef4a4 100755 --- a/rootfs/etc/nginx/template/nginx.tmpl +++ b/rootfs/etc/nginx/template/nginx.tmpl @@ -763,6 +763,10 @@ stream { {{ end }} {{ end }} proxy_timeout {{ $cfg.ProxyStreamTimeout }}; + proxy_next_upstream {{ if $cfg.ProxyStreamNextUpstream }}on{{ else }}off{{ end }}; + proxy_next_upstream_timeout {{ $cfg.ProxyStreamNextUpstreamTimeout }}; + proxy_next_upstream_tries {{ $cfg.ProxyStreamNextUpstreamTries }}; + proxy_pass upstream_balancer; {{ if $tcpServer.Backend.ProxyProtocol.Encode }} proxy_protocol on; @@ -791,6 +795,9 @@ stream { {{ end }} proxy_responses {{ $cfg.ProxyStreamResponses }}; proxy_timeout {{ $cfg.ProxyStreamTimeout }}; + proxy_next_upstream {{ if $cfg.ProxyStreamNextUpstream }}on{{ else }}off{{ end }}; + proxy_next_upstream_timeout {{ $cfg.ProxyStreamNextUpstreamTimeout }}; + proxy_next_upstream_tries {{ $cfg.ProxyStreamNextUpstreamTries }}; proxy_pass upstream_balancer; } {{ end }}