Merge pull request #1777 from aledbf/stream_responses

Add setting to configure proxy responses in the stream section
This commit is contained in:
Manuel Alejandro de Brito Fontes 2017-11-30 18:40:27 -03:00 committed by GitHub
commit 738d83985e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 1 deletions

View file

@ -85,6 +85,7 @@ The following table shows a configuration option's name, type, and the default v
|[upstream-keepalive-connections](#upstream-keepalive-connections)|int|32|
|[limit-conn-zone-variable](#limit-conn-zone-variable)|string|"$binary_remote_addr"|
|[proxy-stream-timeout](#proxy-stream-timeout)|string|"600s"|
|[proxy-stream-responses](#proxy-stream-responses)|int|1|
|[bind-address-ipv4](#bind-address-ipv4)|[]string|""|
|[bind-address-ipv6](#bind-address-ipv6)|[]string|""|
|[forwarded-for-header](#forwarded-for-header)|string|"X-Forwarded-For"|
@ -507,6 +508,13 @@ 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
## 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.
_References:_
- http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses
## bind-address-ipv4
Sets the addresses on which the server will accept requests instead of *. It should be noted that these addresses must exist in the runtime environment or the controller will crash loop.

View file

@ -388,6 +388,12 @@ type Configuration struct {
// http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_timeout
ProxyStreamTimeout string `json:"proxy-stream-timeout,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
// Default: 1
ProxyStreamResponses int `json:"proxy-stream-responses,omitempty"`
// Sets the ipv4 addresses on which the server will accept requests.
BindAddressIpv4 []string `json:"bind-address-ipv4,omitempty"`
@ -473,6 +479,7 @@ func NewDefault() Configuration {
ServerNameHashMaxSize: 1024,
ProxyHeadersHashMaxSize: 512,
ProxyHeadersHashBucketSize: 64,
ProxyStreamResponses: 1,
ShowServerTokens: true,
SSLBufferSize: sslBufferSize,
SSLCiphers: sslCiphers,

View file

@ -37,6 +37,7 @@ const (
proxyRealIPCIDR = "proxy-real-ip-cidr"
bindAddress = "bind-address"
httpRedirectCode = "http-redirect-code"
proxyStreamResponses = "proxy-stream-responses"
)
var (
@ -114,6 +115,17 @@ func ReadConfig(src map[string]string) config.Configuration {
}
}
streamResponses := 1
if val, ok := conf[proxyStreamResponses]; ok {
delete(conf, proxyStreamResponses)
j, err := strconv.Atoi(val)
if err != nil {
glog.Warningf("%v is not a valid number: %v", val, err)
} else {
streamResponses = j
}
}
to := config.NewDefault()
to.CustomHTTPErrors = filterErrors(errors)
to.SkipAccessLogURLs = skipUrls
@ -122,6 +134,7 @@ func ReadConfig(src map[string]string) config.Configuration {
to.BindAddressIpv4 = bindAddressIpv4List
to.BindAddressIpv6 = bindAddressIpv6List
to.HTTPRedirectCode = redirectCode
to.ProxyStreamResponses = streamResponses
config := &mapstructure.DecoderConfig{
Metadata: nil,

View file

@ -514,7 +514,7 @@ stream {
listen [::]:{{ $udpServer.Port }} udp;
{{ end }}
{{ end }}
proxy_responses 1;
proxy_responses {{ $cfg.ProxyStreamResponses }};
proxy_timeout {{ $cfg.ProxyStreamTimeout }};
proxy_pass udp-{{ $udpServer.Port }}-{{ $udpServer.Backend.Namespace }}-{{ $udpServer.Backend.Name }}-{{ $udpServer.Backend.Port }};
}