Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Sep 29, 2017
1 parent f549e03 commit f253d24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions controllers/nginx/pkg/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,17 +673,20 @@ func buildForwardedFor(input interface{}) string {
func trustHTTPHeaders(input interface{}) bool {
conf, ok := input.(config.TemplateConfig)
if !ok {
glog.Errorf("%v", input)
return true
}

return conf.Cfg.RealClientFrom == "http-proxy" ||
(conf.Cfg.RealClientFrom == "auto" && !conf.Cfg.UseProxyProtocol &&
(conf.PublishService != nil && conf.PublishService.Spec.Type == apiv1.ServiceTypeLoadBalancer))
(conf.Cfg.RealClientFrom == "auto" && !conf.Cfg.UseProxyProtocol ||
(conf.Cfg.RealClientFrom == "auto" && conf.PublishService != nil &&
conf.PublishService.Spec.Type == apiv1.ServiceTypeLoadBalancer))
}

func trustProxyProtocol(input interface{}) bool {
conf, ok := input.(config.TemplateConfig)
if !ok {
glog.Errorf("%v", input)
return true
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/nginx/rootfs/etc/nginx/template/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ http {
# Trust HTTP X-Forwarded-* Headers, but use direct values if they're missing.
map {{ buildForwardedFor $cfg.ForwardedForHeader }} $the_real_ip {
# Get IP address from X-Forwarded-For HTTP header
default $remote_addr;
'' $realip_remote_addr;
default $realip_remote_addr;
'' $remote_addr;
}

# trust http_x_forwarded_proto headers correctly indicate ssl offloading
Expand Down

0 comments on commit f253d24

Please sign in to comment.