Allow config to disable geoip (#2202)

For a offline or private cloud environment, geoip is not needed.
Implementing https://github.com/kubernetes/ingress-nginx/issues/2179
This commit is contained in:
Oilbeater 2018-03-19 00:30:05 +08:00 committed by Manuel Alejandro de Brito Fontes
parent c90a4e811e
commit 5c02d700cb
4 changed files with 15 additions and 2 deletions

View file

@ -82,6 +82,7 @@ The following table shows a configuration option's name, type, and the default v
|[ssl-buffer-size](#ssl-buffer-size)|string|"4k"| |[ssl-buffer-size](#ssl-buffer-size)|string|"4k"|
|[use-proxy-protocol](#use-proxy-protocol)|bool|"false"| |[use-proxy-protocol](#use-proxy-protocol)|bool|"false"|
|[use-gzip](#use-gzip)|bool|"true"| |[use-gzip](#use-gzip)|bool|"true"|
|[use-geoip](#use-geoip)|bool|"true"|
|[enable-brotli](#enable-brotli)|bool|"true"| |[enable-brotli](#enable-brotli)|bool|"true"|
|[brotli-level](#brotli-level)|int|4| |[brotli-level](#brotli-level)|int|4|
|[brotli-types](#brotli-types)|string|"application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component"| |[brotli-types](#brotli-types)|string|"application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component"|
@ -461,6 +462,11 @@ Enables or disables the [PROXY protocol](https://www.nginx.com/resources/admin-g
Enables or disables compression of HTTP responses using the ["gzip" module](http://nginx.org/en/docs/http/ngx_http_gzip_module.html). Enables or disables compression of HTTP responses using the ["gzip" module](http://nginx.org/en/docs/http/ngx_http_gzip_module.html).
The default mime type list to compress is: `application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component`. The default mime type list to compress is: `application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component`.
## use-geoip
Enables or disables ["geoip" module](http://nginx.org/en/docs/http/ngx_http_geoip_module.html) that creates variables with values depending on the client IP address, using the precompiled MaxMind databases.
The default value is true.
## enable-brotli ## enable-brotli
Enables or disables compression of HTTP responses using the ["brotli" module](https://github.com/google/ngx_brotli). Enables or disables compression of HTTP responses using the ["brotli" module](https://github.com/google/ngx_brotli).

File diff suppressed because one or more lines are too long

View file

@ -340,6 +340,10 @@ type Configuration struct {
// http://nginx.org/en/docs/http/ngx_http_gzip_module.html // http://nginx.org/en/docs/http/ngx_http_gzip_module.html
UseGzip bool `json:"use-gzip,omitempty"` UseGzip bool `json:"use-gzip,omitempty"`
// Enables or disables the use of the nginx geoip module that creates variables with values depending on the client IP
// http://nginx.org/en/docs/http/ngx_http_geoip_module.html
UseGeoIP bool `json:"use-geoip,omitempty"`
// Enables or disables the use of the NGINX Brotli Module for compression // Enables or disables the use of the NGINX Brotli Module for compression
// https://github.com/google/ngx_brotli // https://github.com/google/ngx_brotli
EnableBrotli bool `json:"enable-brotli,omitempty"` EnableBrotli bool `json:"enable-brotli,omitempty"`
@ -542,6 +546,7 @@ func NewDefault() Configuration {
SSLSessionTimeout: sslSessionTimeout, SSLSessionTimeout: sslSessionTimeout,
EnableBrotli: false, EnableBrotli: false,
UseGzip: true, UseGzip: true,
UseGeoIP: true,
WorkerProcesses: strconv.Itoa(runtime.NumCPU()), WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
WorkerShutdownTimeout: "10s", WorkerShutdownTimeout: "10s",
LoadBalanceAlgorithm: defaultLoadBalancerAlgorithm, LoadBalanceAlgorithm: defaultLoadBalancerAlgorithm,

View file

@ -81,6 +81,7 @@ http {
set_real_ip_from {{ $trusted_ip }}; set_real_ip_from {{ $trusted_ip }};
{{ end }} {{ end }}
{{ if $cfg.UseGeoIP }}
{{/* databases used to determine the country depending on the client IP address */}} {{/* databases used to determine the country depending on the client IP address */}}
{{/* http://nginx.org/en/docs/http/ngx_http_geoip_module.html */}} {{/* http://nginx.org/en/docs/http/ngx_http_geoip_module.html */}}
{{/* this is require to calculate traffic for individual country using GeoIP in the status page */}} {{/* this is require to calculate traffic for individual country using GeoIP in the status page */}}
@ -88,6 +89,7 @@ http {
geoip_city /etc/nginx/geoip/GeoLiteCity.dat; geoip_city /etc/nginx/geoip/GeoLiteCity.dat;
geoip_org /etc/nginx/geoip/GeoIPASNum.dat; geoip_org /etc/nginx/geoip/GeoIPASNum.dat;
geoip_proxy_recursive on; geoip_proxy_recursive on;
{{ end }}
{{ if $cfg.EnableVtsStatus }} {{ if $cfg.EnableVtsStatus }}
vhost_traffic_status_zone shared:vhost_traffic_status:{{ $cfg.VtsStatusZoneSize }}; vhost_traffic_status_zone shared:vhost_traffic_status:{{ $cfg.VtsStatusZoneSize }};