Hello!
Is it possible to add/configure geoIP headers in Kong?
I didn’t find any solution…
I want to move configuration from our existent nginx controller to kong ingress controller.
And I don’t how to to deal with such configuration on Kong:
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers X-GeoIP-Country $geoip_country_code;
more_set_headers X-GeoIP-Country-Name $geoip_country_name;
more_set_headers X-GeoIP-Region-Name $geoip_region_name;
more_set_headers X-GeoIP-City $geoip_city;
more_set_headers X-GeoIP-Postal-Code $geoip_postal_code;
more_set_headers "X-XSS-Protection: 1; mode=block";
more_set_headers "X-Frame-Options: SAMEORIGIN";
Thank in advance for any tips.
hbagdi
September 1, 2020, 4:03pm
2
You can do this globally in Kong but not for a specific service.
If you would like to do it globally, you can use Nginx directive injection .
@hbagdi Thanks for your reply. Sorry, but could you give me a short example, because it’s not so easy to understand how-to implement it…
as I see I should re-run kong with some extra env variables, something like this?:
KONG_NGINX_HTTP_GEOIP_COUNTRY=“$geoip_country_code”
tested it in such way:
- name: KONG_NGINX_PROXY_ADD_HEADER
value: X-GeoIP-Country $geoip_country_code
but kong gets in CrashLoopbackOff.
It doesn’t recognize variable/symbol ‘$’
logs:
Error: could not prepare Kong prefix at /kong_prefix: nginx configuration is invalid (exit code 1):
nginx: [warn] load balancing method redefined in /kong_prefix/nginx-kong.conf:57
nginx: [emerg] unknown “geoip_country_code” variable
nginx: configuration file /kong_prefix/nginx.conf test failed
Maybe I should somehow enable nginx geoip module in kong at first?
@hbagdi help please.
hbagdi
September 11, 2020, 11:38pm
5
geoip module doesn’t ship with Kong and you can’t do this.