Skip to content

Commit

Permalink
Merge pull request #94 from aledbf/server-tokens
Browse files Browse the repository at this point in the history
Add support to disable server_tokens directive
  • Loading branch information
aledbf authored Jan 12, 2017
2 parents 717594a + af9375a commit 54d9762
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 14 additions & 8 deletions controllers/nginx/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ type Configuration struct {
// http://nginx.org/en/docs/http/ngx_http_core_module.html#server_names_hash_bucket_size
ServerNameHashBucketSize int `json:"server-name-hash-bucket-size,omitempty"`

// Enables or disables emitting nginx version in error messages and in the “Server” response header field.
// http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens
// Default: true
ShowServerTokens bool `json:"server-tokens"`

// Enabled ciphers list to enabled. The ciphers are specified in the format understood by
// the OpenSSL library
// http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_ciphers
Expand Down Expand Up @@ -234,6 +239,7 @@ func NewDefault() Configuration {
ProxyRealIPCIDR: defIPCIDR,
ServerNameHashMaxSize: 512,
ServerNameHashBucketSize: 64,
ShowServerTokens: true,
SSLBufferSize: sslBufferSize,
SSLCiphers: sslCiphers,
SSLProtocols: sslProtocols,
Expand Down Expand Up @@ -266,13 +272,13 @@ func NewDefault() Configuration {
}

type TemplateConfig struct {
BacklogSize int
Backends []*ingress.Backend
BacklogSize int
Backends []*ingress.Backend
PassthroughBackends []*ingress.SSLPassthroughBackend
Servers []*ingress.Server
TCPBackends []*ingress.Location
UDPBackends []*ingress.Location
HealthzURI string
CustomErrors bool
Cfg Configuration
Servers []*ingress.Server
TCPBackends []*ingress.Location
UDPBackends []*ingress.Location
HealthzURI string
CustomErrors bool
Cfg Configuration
}
2 changes: 2 additions & 0 deletions controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ http {
gzip_proxied any;
{{ end }}

server_tokens {{ if $cfg.ShowServerTokens }}on{{ else }}off{{ end }};

client_max_body_size "{{ $cfg.BodySize }}";

log_format upstreaminfo '{{ if $cfg.UseProxyProtocol }}$proxy_protocol_addr{{ else }}$remote_addr{{ end }} - '
Expand Down

0 comments on commit 54d9762

Please sign in to comment.