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

Support real-ip in default server #1129

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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}}
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved
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
6 changes: 6 additions & 0 deletions internal/configs/version1/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ http {
ssl_certificate /etc/nginx/secrets/default;
ssl_certificate_key /etc/nginx/secrets/default;

# this is a change check
{{range $setRealIPFrom := .SetRealIPFrom}}
set_real_ip_from {{$setRealIPFrom}};{{end}}
LorcanMcVeigh marked this conversation as resolved.
Show resolved Hide resolved
{{if .RealIPHeader}}real_ip_header {{.RealIPHeader}};{{end}}
{{if .RealIPRecursive}}real_ip_recursive on;{{end}}

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