Skip to content

Commit

Permalink
Support real-ip in default server
Browse files Browse the repository at this point in the history
  • Loading branch information
LorcanMcVeigh authored Sep 8, 2020
1 parent 739e35a commit 905b69c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/configs/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ func GenerateNginxMainConfig(staticCfgParams *StaticConfigParams, config *Config
ResolverIPV6: config.ResolverIPV6,
ResolverTimeout: config.ResolverTimeout,
ResolverValid: config.ResolverValid,
RealIPHeader: config.RealIPHeader,
RealIPRecursive: config.RealIPRecursive,
SetRealIPFrom: config.SetRealIPFrom,
ServerNamesHashBucketSize: config.MainServerNamesHashBucketSize,
ServerNamesHashMaxSize: config.MainServerNamesHashMaxSize,
ServerTokens: config.ServerTokens,
Expand Down
3 changes: 3 additions & 0 deletions internal/configs/version1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ type MainConfig struct {
ResolverIPV6 bool
ResolverTimeout string
ResolverValid string
RealIPHeader string
RealIPRecursive bool
SetRealIPFrom []string
ServerNamesHashBucketSize string
ServerNamesHashMaxSize string
ServerTokens string
Expand Down
5 changes: 5 additions & 0 deletions internal/configs/version1/nginx-plus.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ http {
ssl_certificate /etc/nginx/secrets/default;
ssl_certificate_key /etc/nginx/secrets/default;

{{range $setRealIPFrom := .SetRealIPFrom}}
set_real_ip_from {{$setRealIPFrom}};{{end}}
{{if .RealIPHeader}}real_ip_header {{.RealIPHeader}};{{end}}
{{if .RealIPRecursive}}real_ip_recursive on;{{end}}

server_name _;
server_tokens "{{.ServerTokens}}";
{{if .DefaultServerAccessLogOff}}
Expand Down
5 changes: 5 additions & 0 deletions internal/configs/version1/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ http {
ssl_certificate /etc/nginx/secrets/default;
ssl_certificate_key /etc/nginx/secrets/default;

{{range $setRealIPFrom := .SetRealIPFrom}}
set_real_ip_from {{$setRealIPFrom}};{{end}}
{{if .RealIPHeader}}real_ip_header {{.RealIPHeader}};{{end}}
{{if .RealIPRecursive}}real_ip_recursive on;{{end}}

server_name _;
server_tokens "{{.ServerTokens}}";
{{if .DefaultServerAccessLogOff}}
Expand Down

0 comments on commit 905b69c

Please sign in to comment.