From 13ab894e6fc6be694960e63f99e187630778b4fe Mon Sep 17 00:00:00 2001 From: zhengjiajin <393926893@qq.com> Date: Tue, 8 Aug 2017 02:01:12 +0800 Subject: [PATCH] feat/proxytimeout support proxy timeout for stream type --- controllers/nginx/pkg/config/config.go | 6 ++++++ controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl | 2 ++ controllers/nginx/test/data/config.json | 1 + 3 files changed, 9 insertions(+) diff --git a/controllers/nginx/pkg/config/config.go b/controllers/nginx/pkg/config/config.go index 7fcf447750..a920c06223 100644 --- a/controllers/nginx/pkg/config/config.go +++ b/controllers/nginx/pkg/config/config.go @@ -319,6 +319,11 @@ type Configuration struct { // 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"` + + // 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"` } // NewDefault returns the default nginx configuration @@ -368,6 +373,7 @@ func NewDefault() Configuration { VariablesHashBucketSize: 64, VariablesHashMaxSize: 2048, UseHTTP2: true, + ProxyStreamTimeout: "600s", Backend: defaults.Backend{ ProxyBodySize: bodySize, ProxyConnectTimeout: 5, diff --git a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl index 771250a9ec..e2513da1b5 100644 --- a/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl +++ b/controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl @@ -584,6 +584,7 @@ stream { server { listen {{ $tcpServer.Port }}{{ if $tcpServer.Backend.UseProxyProtocol }} proxy_protocol{{ end }}; {{ if $IsIPV6Enabled }}listen [::]:{{ $tcpServer.Port }}{{ if $tcpServer.Backend.UseProxyProtocol }} proxy_protocol{{ end }};{{ end }} + proxy_timeout {{ $cfg.ProxyStreamTimeout }}; proxy_pass tcp-{{ $tcpServer.Port }}-{{ $tcpServer.Backend.Namespace }}-{{ $tcpServer.Backend.Name }}-{{ $tcpServer.Backend.Port }}; } @@ -601,6 +602,7 @@ stream { listen {{ $udpServer.Port }} udp; {{ if $IsIPV6Enabled }}listen [::]:{{ $udpServer.Port }} udp;{{ end }} proxy_responses 1; + proxy_timeout {{ $cfg.ProxyStreamTimeout }}; proxy_pass udp-{{ $udpServer.Port }}-{{ $udpServer.Backend.Namespace }}-{{ $udpServer.Backend.Name }}-{{ $udpServer.Backend.Port }}; } {{ end }} diff --git a/controllers/nginx/test/data/config.json b/controllers/nginx/test/data/config.json index 9273cda7c1..6d19958d0d 100644 --- a/controllers/nginx/test/data/config.json +++ b/controllers/nginx/test/data/config.json @@ -38,6 +38,7 @@ "sslSessionTimeout": "10m", "useGzip": true, "useHttp2": true, + "proxyStreamTimeout": "600s", "vtsStatusZoneSize": "10m", "workerProcesses": 1, "limitConnZoneVariable": "$the_real_ip"