Merge pull request #4450 from Shopify/proxy-max-temp-file-size
Add nginx proxy_max_temp_file_size configuration option
This commit is contained in:
commit
b5fecd0dc8
6 changed files with 58 additions and 31 deletions
|
@ -41,6 +41,7 @@ type Config struct {
|
||||||
RequestBuffering string `json:"requestBuffering"`
|
RequestBuffering string `json:"requestBuffering"`
|
||||||
ProxyBuffering string `json:"proxyBuffering"`
|
ProxyBuffering string `json:"proxyBuffering"`
|
||||||
ProxyHTTPVersion string `json:"proxyHTTPVersion"`
|
ProxyHTTPVersion string `json:"proxyHTTPVersion"`
|
||||||
|
ProxyMaxTempFileSize string `json:"proxyMaxTempFileSize"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equal tests for equality between two Configuration types
|
// Equal tests for equality between two Configuration types
|
||||||
|
@ -100,6 +101,10 @@ func (l1 *Config) Equal(l2 *Config) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if l1.ProxyMaxTempFileSize != l2.ProxyMaxTempFileSize {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,5 +205,10 @@ func (a proxy) Parse(ing *networking.Ingress) (interface{}, error) {
|
||||||
config.ProxyHTTPVersion = defBackend.ProxyHTTPVersion
|
config.ProxyHTTPVersion = defBackend.ProxyHTTPVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.ProxyMaxTempFileSize, err = parser.GetStringAnnotation("proxy-max-temp-file-size", ing)
|
||||||
|
if err != nil {
|
||||||
|
config.ProxyMaxTempFileSize = defBackend.ProxyMaxTempFileSize
|
||||||
|
}
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ func (m mockBackend) GetDefaultBackend() defaults.Backend {
|
||||||
ProxyRequestBuffering: "on",
|
ProxyRequestBuffering: "on",
|
||||||
ProxyBuffering: "off",
|
ProxyBuffering: "off",
|
||||||
ProxyHTTPVersion: "1.1",
|
ProxyHTTPVersion: "1.1",
|
||||||
|
ProxyMaxTempFileSize: "1024m",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ func TestProxy(t *testing.T) {
|
||||||
data[parser.GetAnnotationWithPrefix("proxy-request-buffering")] = "off"
|
data[parser.GetAnnotationWithPrefix("proxy-request-buffering")] = "off"
|
||||||
data[parser.GetAnnotationWithPrefix("proxy-buffering")] = "on"
|
data[parser.GetAnnotationWithPrefix("proxy-buffering")] = "on"
|
||||||
data[parser.GetAnnotationWithPrefix("proxy-http-version")] = "1.0"
|
data[parser.GetAnnotationWithPrefix("proxy-http-version")] = "1.0"
|
||||||
|
data[parser.GetAnnotationWithPrefix("proxy-max-temp-file-size")] = "128k"
|
||||||
ing.SetAnnotations(data)
|
ing.SetAnnotations(data)
|
||||||
|
|
||||||
i, err := NewParser(mockBackend{}).Parse(ing)
|
i, err := NewParser(mockBackend{}).Parse(ing)
|
||||||
|
@ -147,6 +149,9 @@ func TestProxy(t *testing.T) {
|
||||||
if p.ProxyHTTPVersion != "1.0" {
|
if p.ProxyHTTPVersion != "1.0" {
|
||||||
t.Errorf("expected 1.0 as proxy-http-version but returned %v", p.ProxyHTTPVersion)
|
t.Errorf("expected 1.0 as proxy-http-version but returned %v", p.ProxyHTTPVersion)
|
||||||
}
|
}
|
||||||
|
if p.ProxyMaxTempFileSize != "128k" {
|
||||||
|
t.Errorf("expected 128k as proxy-max-temp-file-size but returned %v", p.ProxyMaxTempFileSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestProxyWithNoAnnotation(t *testing.T) {
|
func TestProxyWithNoAnnotation(t *testing.T) {
|
||||||
|
@ -196,4 +201,7 @@ func TestProxyWithNoAnnotation(t *testing.T) {
|
||||||
if p.ProxyHTTPVersion != "1.1" {
|
if p.ProxyHTTPVersion != "1.1" {
|
||||||
t.Errorf("expected 1.1 as proxy-http-version but returned %v", p.ProxyHTTPVersion)
|
t.Errorf("expected 1.1 as proxy-http-version but returned %v", p.ProxyHTTPVersion)
|
||||||
}
|
}
|
||||||
|
if p.ProxyMaxTempFileSize != "1024m" {
|
||||||
|
t.Errorf("expected 1024m as proxy-max-temp-file-size but returned %v", p.ProxyMaxTempFileSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -728,6 +728,7 @@ func NewDefault() Configuration {
|
||||||
LimitRateAfter: 0,
|
LimitRateAfter: 0,
|
||||||
ProxyBuffering: "off",
|
ProxyBuffering: "off",
|
||||||
ProxyHTTPVersion: "1.1",
|
ProxyHTTPVersion: "1.1",
|
||||||
|
ProxyMaxTempFileSize: "1024m",
|
||||||
},
|
},
|
||||||
UpstreamKeepaliveConnections: 32,
|
UpstreamKeepaliveConnections: 32,
|
||||||
UpstreamKeepaliveTimeout: 60,
|
UpstreamKeepaliveTimeout: 60,
|
||||||
|
|
|
@ -927,6 +927,7 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
ProxyRedirectFrom: bdef.ProxyRedirectFrom,
|
ProxyRedirectFrom: bdef.ProxyRedirectFrom,
|
||||||
ProxyBuffering: bdef.ProxyBuffering,
|
ProxyBuffering: bdef.ProxyBuffering,
|
||||||
ProxyHTTPVersion: bdef.ProxyHTTPVersion,
|
ProxyHTTPVersion: bdef.ProxyHTTPVersion,
|
||||||
|
ProxyMaxTempFileSize: bdef.ProxyMaxTempFileSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize default server and root location
|
// initialize default server and root location
|
||||||
|
|
|
@ -154,4 +154,8 @@ type Backend struct {
|
||||||
// Modifies the HTTP version the proxy uses to interact with the backend.
|
// 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
|
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version
|
||||||
ProxyHTTPVersion string `json:"proxy-http-version"`
|
ProxyHTTPVersion string `json:"proxy-http-version"`
|
||||||
|
|
||||||
|
// Sets the maximum temp file size when proxy-buffers capacity is exceeded.
|
||||||
|
// http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size
|
||||||
|
ProxyMaxTempFileSize string `json:"proxy-max-temp-file-size"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1201,6 +1201,9 @@ stream {
|
||||||
proxy_buffering {{ $location.Proxy.ProxyBuffering }};
|
proxy_buffering {{ $location.Proxy.ProxyBuffering }};
|
||||||
proxy_buffer_size {{ $location.Proxy.BufferSize }};
|
proxy_buffer_size {{ $location.Proxy.BufferSize }};
|
||||||
proxy_buffers {{ $location.Proxy.BuffersNumber }} {{ $location.Proxy.BufferSize }};
|
proxy_buffers {{ $location.Proxy.BuffersNumber }} {{ $location.Proxy.BufferSize }};
|
||||||
|
{{ if isValidByteSize $location.Proxy.ProxyMaxTempFileSize true }}
|
||||||
|
proxy_max_temp_file_size {{ $location.Proxy.ProxyMaxTempFileSize }};
|
||||||
|
{{ end }}
|
||||||
proxy_request_buffering {{ $location.Proxy.RequestBuffering }};
|
proxy_request_buffering {{ $location.Proxy.RequestBuffering }};
|
||||||
proxy_http_version {{ $location.Proxy.ProxyHTTPVersion }};
|
proxy_http_version {{ $location.Proxy.ProxyHTTPVersion }};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue