Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions nginx-controller/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
all: push

VERSION = 0.6.0
VERSION = 0.6.3-merged
TAG = $(VERSION)
PREFIX = nginxdemos/nginx-ingress
PREFIX = quay.io/nico_schieder/nginxinc-kubernetes-ingress

DOCKER_RUN = docker run --rm -v $(shell pwd)/../:/go/src/github.com/nginxinc/kubernetes-ingress -w /go/src/github.com/nginxinc/kubernetes-ingress/nginx-controller/
DOCKER_RUN = docker run --rm -v $(shell pwd)/../:/go/src/github.com/nginxinc/kubernetes-ingress:Z -w /go/src/github.com/nginxinc/kubernetes-ingress/nginx-controller/
GOLANG_CONTAINER = golang:1.6
DOCKERFILE = Dockerfile

BUILD_IN_CONTAINER = 1
BUILD_IN_CONTAINER = 0
PUSH_TO_GCR =

ifeq ($(PUSH_TO_GCR),1)
Expand Down
7 changes: 7 additions & 0 deletions nginx-controller/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ func (lbc *LoadBalancerController) syncCfgm(key string) {
if proxyReadTimeout, exists := cfgm.Data["proxy-read-timeout"]; exists {
cfg.ProxyReadTimeout = proxyReadTimeout
}
if proxyHideHeaders, exists, err := nginx.GetMapKeyAsStringSlice(cfgm.Data, "proxy-hide-headers", cfgm); exists {
if err != nil {
glog.Error(err)
} else {
cfg.ProxyHideHeaders = proxyHideHeaders
}
}
if clientMaxBodySize, exists := cfgm.Data["client-max-body-size"]; exists {
cfg.ClientMaxBodySize = clientMaxBodySize
}
Expand Down
1 change: 1 addition & 0 deletions nginx-controller/nginx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Config struct {
ProxyBufferSize string
ProxyMaxTempFileSize string
ProxyProtocol bool
ProxyHideHeaders []string
HSTS bool
HSTSMaxAge int64
HSTSIncludeSubdomains bool
Expand Down
13 changes: 13 additions & 0 deletions nginx-controller/nginx/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
RealIPHeader: ingCfg.RealIPHeader,
SetRealIPFrom: ingCfg.SetRealIPFrom,
RealIPRecursive: ingCfg.RealIPRecursive,
ProxyHideHeaders: ingCfg.ProxyHideHeaders,
}

if pemFile, ok := pems[serverName]; ok {
Expand Down Expand Up @@ -160,6 +161,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
RealIPHeader: ingCfg.RealIPHeader,
SetRealIPFrom: ingCfg.SetRealIPFrom,
RealIPRecursive: ingCfg.RealIPRecursive,
ProxyHideHeaders: ingCfg.ProxyHideHeaders,
}

if pemFile, ok := pems[emptyHost]; ok {
Expand Down Expand Up @@ -190,6 +192,17 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
if proxyReadTimeout, exists := ingEx.Ingress.Annotations["nginx.org/proxy-read-timeout"]; exists {
ingCfg.ProxyReadTimeout = proxyReadTimeout
}
if proxyHideHeaders, exists, err := GetMapKeyAsStringSlice(ingEx.Ingress.Annotations, "nginx.org/proxy-hide-headers", ingEx.Ingress); exists {
if err != nil {
glog.Error(err)
} else {
if ingCfg.ProxyHideHeaders == nil || len(ingCfg.ProxyHideHeaders) == 0 {
ingCfg.ProxyHideHeaders = proxyHideHeaders
} else {
ingCfg.ProxyHideHeaders = append(ingCfg.ProxyHideHeaders, proxyHideHeaders...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the nginx.org/proxy-hide-headers annotations exists, it's better to overwrite the value provided by the configmap. Such a behavior is consistent with the behaviour of the proxy_hide_header NGINX directive.

}
}
}
if clientMaxBodySize, exists := ingEx.Ingress.Annotations["nginx.org/client-max-body-size"]; exists {
ingCfg.ClientMaxBodySize = clientMaxBodySize
}
Expand Down
3 changes: 3 additions & 0 deletions nginx-controller/nginx/ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ server {
server_name {{$server.Name}};
{{end}}

{{range $proxyHideHeader := $server.ProxyHideHeaders}}
proxy_hide_header {{$proxyHideHeader}};{{end}}

{{if $server.SSL}}
if ($scheme = http) {
return 301 https://$host$request_uri;
Expand Down
1 change: 1 addition & 0 deletions nginx-controller/nginx/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Server struct {
HSTS bool
HSTSMaxAge int64
HSTSIncludeSubdomains bool
ProxyHideHeaders []string

// http://nginx.org/en/docs/http/ngx_http_realip_module.html
RealIPHeader string
Expand Down