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
|
@ -25,22 +25,23 @@ import (
|
||||||
|
|
||||||
// Config returns the proxy timeout to use in the upstream server/s
|
// Config returns the proxy timeout to use in the upstream server/s
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BodySize string `json:"bodySize"`
|
BodySize string `json:"bodySize"`
|
||||||
ConnectTimeout int `json:"connectTimeout"`
|
ConnectTimeout int `json:"connectTimeout"`
|
||||||
SendTimeout int `json:"sendTimeout"`
|
SendTimeout int `json:"sendTimeout"`
|
||||||
ReadTimeout int `json:"readTimeout"`
|
ReadTimeout int `json:"readTimeout"`
|
||||||
BuffersNumber int `json:"buffersNumber"`
|
BuffersNumber int `json:"buffersNumber"`
|
||||||
BufferSize string `json:"bufferSize"`
|
BufferSize string `json:"bufferSize"`
|
||||||
CookieDomain string `json:"cookieDomain"`
|
CookieDomain string `json:"cookieDomain"`
|
||||||
CookiePath string `json:"cookiePath"`
|
CookiePath string `json:"cookiePath"`
|
||||||
NextUpstream string `json:"nextUpstream"`
|
NextUpstream string `json:"nextUpstream"`
|
||||||
NextUpstreamTimeout int `json:"nextUpstreamTimeout"`
|
NextUpstreamTimeout int `json:"nextUpstreamTimeout"`
|
||||||
NextUpstreamTries int `json:"nextUpstreamTries"`
|
NextUpstreamTries int `json:"nextUpstreamTries"`
|
||||||
ProxyRedirectFrom string `json:"proxyRedirectFrom"`
|
ProxyRedirectFrom string `json:"proxyRedirectFrom"`
|
||||||
ProxyRedirectTo string `json:"proxyRedirectTo"`
|
ProxyRedirectTo string `json:"proxyRedirectTo"`
|
||||||
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,
|
||||||
|
|
|
@ -912,21 +912,22 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
||||||
|
|
||||||
bdef := n.store.GetDefaultBackend()
|
bdef := n.store.GetDefaultBackend()
|
||||||
ngxProxy := proxy.Config{
|
ngxProxy := proxy.Config{
|
||||||
BodySize: bdef.ProxyBodySize,
|
BodySize: bdef.ProxyBodySize,
|
||||||
ConnectTimeout: bdef.ProxyConnectTimeout,
|
ConnectTimeout: bdef.ProxyConnectTimeout,
|
||||||
SendTimeout: bdef.ProxySendTimeout,
|
SendTimeout: bdef.ProxySendTimeout,
|
||||||
ReadTimeout: bdef.ProxyReadTimeout,
|
ReadTimeout: bdef.ProxyReadTimeout,
|
||||||
BuffersNumber: bdef.ProxyBuffersNumber,
|
BuffersNumber: bdef.ProxyBuffersNumber,
|
||||||
BufferSize: bdef.ProxyBufferSize,
|
BufferSize: bdef.ProxyBufferSize,
|
||||||
CookieDomain: bdef.ProxyCookieDomain,
|
CookieDomain: bdef.ProxyCookieDomain,
|
||||||
CookiePath: bdef.ProxyCookiePath,
|
CookiePath: bdef.ProxyCookiePath,
|
||||||
NextUpstream: bdef.ProxyNextUpstream,
|
NextUpstream: bdef.ProxyNextUpstream,
|
||||||
NextUpstreamTimeout: bdef.ProxyNextUpstreamTimeout,
|
NextUpstreamTimeout: bdef.ProxyNextUpstreamTimeout,
|
||||||
NextUpstreamTries: bdef.ProxyNextUpstreamTries,
|
NextUpstreamTries: bdef.ProxyNextUpstreamTries,
|
||||||
RequestBuffering: bdef.ProxyRequestBuffering,
|
RequestBuffering: bdef.ProxyRequestBuffering,
|
||||||
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