Use dynamic load of modules
This commit is contained in:
parent
91c6d1a081
commit
e659efbfdb
3 changed files with 57 additions and 5 deletions
|
@ -652,11 +652,6 @@ type Configuration struct {
|
||||||
// +optional
|
// +optional
|
||||||
GlobalExternalAuth GlobalExternalAuth `json:"global-external-auth"`
|
GlobalExternalAuth GlobalExternalAuth `json:"global-external-auth"`
|
||||||
|
|
||||||
// EnableInfluxDB enables the nginx InfluxDB extension
|
|
||||||
// http://github.com/influxdata/nginx-influxdb-module/
|
|
||||||
// By default this is disabled
|
|
||||||
EnableInfluxDB bool `json:"enable-influxdb"`
|
|
||||||
|
|
||||||
// Checksum contains a checksum of the configmap configuration
|
// Checksum contains a checksum of the configmap configuration
|
||||||
Checksum string `json:"-"`
|
Checksum string `json:"-"`
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,8 @@ var (
|
||||||
"shouldLoadOpentracingModule": shouldLoadOpentracingModule,
|
"shouldLoadOpentracingModule": shouldLoadOpentracingModule,
|
||||||
"buildModSecurityForLocation": buildModSecurityForLocation,
|
"buildModSecurityForLocation": buildModSecurityForLocation,
|
||||||
"buildMirrorLocations": buildMirrorLocations,
|
"buildMirrorLocations": buildMirrorLocations,
|
||||||
|
"shouldLoadAuthDigestModule": shouldLoadAuthDigestModule,
|
||||||
|
"shouldLoadInfluxDBModule": shouldLoadInfluxDBModule,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1415,3 +1417,45 @@ proxy_pass %v;
|
||||||
|
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shouldLoadAuthDigestModule determines whether or not the ngx_http_auth_digest_module module needs to be loaded.
|
||||||
|
func shouldLoadAuthDigestModule(s interface{}) bool {
|
||||||
|
servers, ok := s.([]*ingress.Server)
|
||||||
|
if !ok {
|
||||||
|
klog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, server := range servers {
|
||||||
|
for _, location := range server.Locations {
|
||||||
|
if !location.BasicDigestAuth.Secured {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if location.BasicDigestAuth.Type == "digest" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// shouldLoadInfluxDBModule determines whether or not the ngx_http_auth_digest_module module needs to be loaded.
|
||||||
|
func shouldLoadInfluxDBModule(s interface{}) bool {
|
||||||
|
servers, ok := s.([]*ingress.Server)
|
||||||
|
if !ok {
|
||||||
|
klog.Errorf("expected an '[]*ingress.Server' type but %T was returned", s)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, server := range servers {
|
||||||
|
for _, location := range server.Locations {
|
||||||
|
if location.InfluxDB.InfluxDBEnabled {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,19 @@ pid {{ .PID }};
|
||||||
load_module /etc/nginx/modules/ngx_http_geoip2_module.so;
|
load_module /etc/nginx/modules/ngx_http_geoip2_module.so;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if $cfg.EnableBrotli }}
|
||||||
|
load_module /etc/nginx/modules/ngx_http_brotli_filter_module.so;
|
||||||
|
load_module /etc/nginx/modules/ngx_http_brotli_static_module.so;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if (shouldLoadInfluxDBModule $servers) }}
|
||||||
|
load_module /etc/nginx/modules/ngx_http_influxdb_module.so;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if (shouldLoadAuthDigestModule $servers) }}
|
||||||
|
load_module /etc/nginx/modules/ngx_http_auth_digest_module.so;
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if (shouldLoadModSecurityModule $cfg $servers) }}
|
{{ if (shouldLoadModSecurityModule $cfg $servers) }}
|
||||||
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
|
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue