Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Fix stats by country in nginx status page #1235

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Changes from all commits
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
8 changes: 7 additions & 1 deletion ingress/controllers/nginx/nginx.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,24 @@ events {
}

http {
{{/* we use the value of the header X-Forwarded-For to be able to use the geo_ip module */}}
real_ip_header X-Forwarded-For;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my own education, can it geo locate based on src ip as well?

Copy link
Contributor Author

@aledbf aledbf Jun 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that's the default if no X-Forwarded-For header is present in the request

set_real_ip_from 0.0.0.0/0;
real_ip_recursive on;

{{/* 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;
geoip_proxy_recursive on;

{{- 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 section 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;';
init_by_lua_block {
require("error_page")
Expand Down