Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuring pxoxy-buffer-settings #68

Merged
merged 1 commit into from
Nov 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions nginx-controller/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,22 @@ func (lbc *LoadBalancerController) syncCfgm(key string) {
if logFormat, exists := cfgm.Data["log-format"]; exists {
cfg.MainLogFormat = logFormat
}
if proxyBufferingStr, exists := cfgm.Data["proxy-buffering"]; exists {
if ProxyBuffering, err := strconv.ParseBool(proxyBufferingStr); err == nil {
cfg.ProxyBuffering = ProxyBuffering
} else {
glog.Errorf("In configmap %v/%v 'proxy-buffering' contains invalid declaration: %v, ignoring", cfgm.Namespace, cfgm.Name, err)
}
}
if proxyBuffers, exists := cfgm.Data["proxy-buffers"]; exists {
cfg.ProxyBuffers = proxyBuffers
}
if proxyBufferSize, exists := cfgm.Data["proxy-buffer-size"]; exists {
cfg.ProxyBufferSize = proxyBufferSize
}
if proxyMaxTempFileSize, exists := cfgm.Data["proxy-max-temp-file-size"]; exists {
cfg.ProxyMaxTempFileSize = proxyMaxTempFileSize
}
}
lbc.cnf.UpdateConfig(cfg)

Expand Down
5 changes: 5 additions & 0 deletions nginx-controller/nginx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ type Config struct {
MainServerNamesHashBucketSize string
MainServerNamesHashMaxSize string
MainLogFormat string
ProxyBuffering bool
ProxyBuffers string
ProxyBufferSize string
ProxyMaxTempFileSize string
}

// NewDefaultConfig creates a Config with default values
Expand All @@ -18,5 +22,6 @@ func NewDefaultConfig() *Config {
ProxyReadTimeout: "60s",
ClientMaxBodySize: "1m",
MainServerNamesHashMaxSize: "512",
ProxyBuffering: true,
}
}
36 changes: 28 additions & 8 deletions nginx-controller/nginx/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
glog.Errorf("In %v/%v nginx.org/http2 contains invalid declaration: %v, ignoring", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err)
}
}
if proxyBufferingStr, exists := ingEx.Ingress.Annotations["nginx.org/proxy-buffering"]; exists {
if ProxyBuffering, err := strconv.ParseBool(proxyBufferingStr); err == nil {
ingCfg.ProxyBuffering = ProxyBuffering
} else {
glog.Errorf("In %v/%v nginx.org/proxy-buffering contains invalid declaration: %v, ignoring", ingEx.Ingress.Namespace, ingEx.Ingress.Name, err)
}
}
if proxyBuffers, exists := ingEx.Ingress.Annotations["nginx.org/proxy-buffers"]; exists {
ingCfg.ProxyBuffers = proxyBuffers
}
if proxyBufferSize, exists := ingEx.Ingress.Annotations["nginx.org/proxy-buffer-size"]; exists {
ingCfg.ProxyBufferSize = proxyBufferSize
}
if proxyMaxTempFileSize, exists := ingEx.Ingress.Annotations["nginx.org/proxy-max-temp-file-size"]; exists {
ingCfg.ProxyMaxTempFileSize = proxyMaxTempFileSize
}
return ingCfg
}

Expand Down Expand Up @@ -252,14 +268,18 @@ func getSSLServices(ingEx *IngressEx) map[string]bool {

func createLocation(path string, upstream Upstream, cfg *Config, websocket bool, rewrite string, ssl bool) Location {
loc := Location{
Path: path,
Upstream: upstream,
ProxyConnectTimeout: cfg.ProxyConnectTimeout,
ProxyReadTimeout: cfg.ProxyReadTimeout,
ClientMaxBodySize: cfg.ClientMaxBodySize,
Websocket: websocket,
Rewrite: rewrite,
SSL: ssl,
Path: path,
Upstream: upstream,
ProxyConnectTimeout: cfg.ProxyConnectTimeout,
ProxyReadTimeout: cfg.ProxyReadTimeout,
ClientMaxBodySize: cfg.ClientMaxBodySize,
Websocket: websocket,
Rewrite: rewrite,
SSL: ssl,
ProxyBuffering: cfg.ProxyBuffering,
ProxyBuffers: cfg.ProxyBuffers,
ProxyBufferSize: cfg.ProxyBufferSize,
ProxyMaxTempFileSize: cfg.ProxyMaxTempFileSize,
}

return loc
Expand Down
11 changes: 11 additions & 0 deletions nginx-controller/nginx/ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ server {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_buffering {{if $location.ProxyBuffering}}on{{else}}off{{end}};
{{- if $location.ProxyBuffers}}
proxy_buffers {{$location.ProxyBuffers}};
{{- end}}
{{- if $location.ProxyBufferSize}}
proxy_buffer_size {{$location.ProxyBufferSize}};
{{- end}}
{{- if $location.ProxyMaxTempFileSize}}
proxy_max_temp_file_size {{$location.ProxyMaxTempFileSize}};
{{- end}}
{{if $location.SSL}}
proxy_pass https://{{$location.Upstream.Name}}{{$location.Rewrite}};
{{else}}
Expand Down
20 changes: 12 additions & 8 deletions nginx-controller/nginx/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ type Server struct {

// Location describes an NGINX location
type Location struct {
Path string
Upstream Upstream
ProxyConnectTimeout string
ProxyReadTimeout string
ClientMaxBodySize string
Websocket bool
Rewrite string
SSL bool
Path string
Upstream Upstream
ProxyConnectTimeout string
ProxyReadTimeout string
ClientMaxBodySize string
Websocket bool
Rewrite string
SSL bool
ProxyBuffering bool
ProxyBuffers string
ProxyBufferSize string
ProxyMaxTempFileSize string
}

// NginxMainConfig describe the main NGINX configuration file
Expand Down