Add support for geoip in stats
This commit is contained in:
parent
675ce396ac
commit
6968e23f8d
2 changed files with 18 additions and 1 deletions
|
@ -19,6 +19,12 @@ RUN apt-get update && apt-get install -y \
|
|||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Download of GeoIP databases
|
||||
RUN curl -sSL -o /etc/nginx/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz \
|
||||
&& curl -sSL -o /etc/nginx/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz \
|
||||
&& gunzip /etc/nginx/GeoIP.dat.gz \
|
||||
&& gunzip /etc/nginx/GeoLiteCity.dat.gz
|
||||
|
||||
COPY nginx-ingress-controller /
|
||||
COPY nginx.tmpl /etc/nginx/template/nginx.tmpl
|
||||
COPY default.conf /etc/nginx/nginx.conf
|
||||
|
|
|
@ -16,7 +16,16 @@ events {
|
|||
}
|
||||
|
||||
http {
|
||||
{{ if $cfg.enableVtsStatus}}vhost_traffic_status_zone shared:vhost_traffic_status:{{ $cfg.vtsStatusZoneSize }};{{ end }}
|
||||
{{/* databases used to determine the country depending on the client IP address */}}
|
||||
{{/* 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 */}}
|
||||
geoip_country /etc/nginx/GeoIP.dat;
|
||||
geoip_city /etc/nginx/GeoLiteCity.dat;
|
||||
|
||||
{{- if $cfg.enableVtsStatus }}
|
||||
vhost_traffic_status_zone shared:vhost_traffic_status:{{ $cfg.vtsStatusZoneSize }};
|
||||
vhost_traffic_status_filter_by_set_key $geoip_country_code country::*;
|
||||
{{ end -}}
|
||||
|
||||
# lus sectrion to return proper error codes when custom pages are used
|
||||
lua_package_path '.?.lua;./etc/nginx/lua/?.lua;/etc/nginx/lua/vendor/lua-resty-http/lib/?.lua;';
|
||||
|
@ -166,6 +175,8 @@ http {
|
|||
more_set_headers "Strict-Transport-Security: max-age={{ $cfg.hstsMaxAge }}{{ if $cfg.hstsIncludeSubdomains }}; includeSubDomains{{ end }}; preload";
|
||||
{{ end -}}
|
||||
|
||||
{{ if $cfg.enableVtsStatus }}vhost_traffic_status_filter_by_set_key $geoip_country_code country::$server_name;{{ end }}
|
||||
|
||||
{{ range $location := $server.Locations }}
|
||||
location {{ $location.Path }} {
|
||||
proxy_set_header Host $host;
|
||||
|
|
Loading…
Reference in a new issue