<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rajesh Nayak on Medium]]></title>
        <description><![CDATA[Stories by Rajesh Nayak on Medium]]></description>
        <link>https://medium.com/@rajesh.nayak_76368?source=rss-4afe590c255------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3Ama8D9PrzVxWtCI</url>
            <title>Stories by Rajesh Nayak on Medium</title>
            <link>https://medium.com/@rajesh.nayak_76368?source=rss-4afe590c255------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:14:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajesh.nayak_76368/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GeoIP2 module to NGINX Ingress controller.]]></title>
            <link>https://medium.com/@rajesh.nayak_76368/geoip2-module-to-nginx-ingress-controller-ef213601d2d6?source=rss-4afe590c255------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef213601d2d6</guid>
            <dc:creator><![CDATA[Rajesh Nayak]]></dc:creator>
            <pubDate>Wed, 11 Oct 2023 08:24:47 GMT</pubDate>
            <atom:updated>2023-10-11T08:26:19.307Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article will help to configure the GeoIP in the Nginx ingress controller using the helm chart</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*nEw-m61Qy69cngpTHRQs4g.png" /></figure><p>You need to create an account on the <strong>MaxMind</strong> website which provides these databases. I chose to take the Lite version. It’s less precise but it’s free: <a href="https://dev.maxmind.com/geoip/geoip2/geolite2/">Sign up for GeoLite2</a>.</p><p>After registering on the site, you can <strong>generate a new license key</strong> in your <a href="https://www.maxmind.com/en/accounts/current/license-key">MaxMind account</a>.</p><p>Configuring the GeoIP in k8s cluster using the helm chart.</p><ol><li>Login to k8s cluster.</li><li>Create a deploy a Nginx header with required values for the application. For example, if we need a Postal code, please add in the Nginx header. Below is the Manifest file for Nginx header.</li></ol><pre>kind: ConfigMap<br>apiVersion: v1<br>metadata:<br>  name: ingress-headers<br>  namespace: default<br>data:<br>  X-Host: $host<br>  X-Geoip-Country-Code: $country_code<br>  X-Geoip-Country: $country_name<br>  X-Geoip-Region-Code: $region_code<br>  X-Geoip-Region: $region_name<br>  X-Geoip-City: $city_name<br>  X-Geoip-Postal-Code: $postal_code<br>  X-Geoip-Latitude: $latitude<br>  X-Geoip-Longitude: $longitude</pre><p>3. Deploy a nginx ingress controller ,config-map with required features of GeoIP.</p><pre>kind: ConfigMap<br>apiVersion: v1<br>metadata:<br>  name: ingress-nginx-controller<br>  namespace: default<br>  labels:<br>    app.kubernetes.io/name: ingress-nginx<br>    app.kubernetes.io/part-of: ingress-nginx<br>data:<br>  enable-underscores-in-headers: &quot;true&quot;<br>  proxy-set-headers: &quot;default/ingress-headers&quot;<br>  enable-brotli: &quot;true&quot;<br>  use-gzip: &quot;true&quot;<br>  gzip-level: &quot;6&quot;<br>  gzip_disable: &quot;msie6&quot;<br>  use-geoip: &quot;false&quot;<br>  use-geoip2: &quot;true&quot;<br>  real-ip-header: &quot;proxy_protocol&quot;<br>  enable-real-ip: &quot;true&quot;<br>  use-forwarded-headers: &quot;true&quot;<br>  forwarded-for-header: &quot;CF-Connecting-IP&quot;<br>  proxy-body-size : &quot;50m&quot;<br>  large-client-header-buffers : &quot;4 32k&quot;<br>  ## proxy-real-ip-cidr: &quot;&quot;  //if you have a cloudflare infront of the Nfinx whitelist the CF source IP here.  <br>  http-snippet: |<br>    geoip2_proxy 0.0.0.0/0;<br>    geoip2_proxy 2000:0:0:0:0:0:0:0/3;<br>    geoip2_proxy_recursive on;<br><br>    map $http_x_country_code $country_code {<br>      default   $http_x_country_code;<br>      &quot;&quot;        $geoip2_city_country_code;<br>    }<br><br>    map $http_x_country_code $country_name {<br>      default   $http_x_country;<br>      &quot;&quot;        $geoip2_city_country_name;<br>    }<br><br>    map $http_x_country_code $region_code {<br>      default   $http_x_region_code;<br>      &quot;&quot;        $geoip2_region_code;<br>    }<br><br>    map $http_x_country_code $region_name {<br>      default   $http_x_region;<br>      &quot;&quot;        $geoip2_region_name;<br>    }<br><br>    map $http_x_country_code $city_name {<br>      default   $http_x_city;<br>      &quot;&quot;        $geoip2_city;<br>    }<br><br>    map $http_x_country_code $postal_code {<br>      default   $http_x_postal_code;<br>      &quot;&quot;        $geoip2_postal_code;<br>    }<br><br>    map $http_x_country_code $latitude {<br>      default   $http_x_latitude;<br>      &quot;&quot;        $geoip2_latitude;<br>    }<br><br>    map $http_x_country_code $longitude {<br>      default   $http_x_longitude;<br>      &quot;&quot;        $geoip2_longitude;<br>    }<br>  server-snippet: |<br>    real_ip_header CF-Connecting-IP;</pre><p>4. Create a BackendConfig for health check of the nginx pods.</p><pre>apiVersion: cloud.google.com/v1<br>kind: BackendConfig<br>metadata:<br>  name: ingress-backendconfig<br>  namespace: default<br>spec:<br>  healthCheck:<br>    requestPath: /healthz<br>    port: 80<br>    type: HTTP</pre><p>5. Use the below values.yaml for nginx ingress controller deployment.</p><pre>controller:<br>  metrics:<br>    enabled: true<br>  service:<br>    type: NodePort<br>    externalTrafficPolicy: &quot;Local&quot;<br>    annotations:<br>      cloud.google.com/neg: &#39;{&quot;exposed_ports&quot;: {&quot;80&quot;:{&quot;name&quot;: &quot;ingress-nginx-neg&quot;}}}&#39;<br>      cloud.google.com/backend-config: &#39;{&quot;default&quot;: &quot;ingress-backendconfig&quot;}&#39;<br>  replicaCount: 2<br>  autoscaling:<br>    enabled: true<br>    minReplicas: 2<br>    maxReplicas: 6<br>    targetMemoryUtilizationPercentage: 75<br>    targetCPUUtilizationPercentage: 75      <br>  resources:<br>    requests:<br>      cpu: &quot;500m&quot;<br>      memory: &quot;1Gi&quot;<br>  extraArgs:<br>    maxmind-edition-ids: &quot;GeoIP2-City&quot;</pre><p>6. Deploy a nginx ingress controller using the below command.</p><pre>helm upgrade --install ingress-nginx ingress-nginx   --repo https://kubernetes.github.io/ingress-nginx   --namespace default   --set controller.maxmindLicenseKey=&lt;maxmindLicenseKey&gt;   --set controller.extraArgs.maxmind-edition-ids=&quot;GeoLite2-City&quot;   --set controller.service.externalTrafficPolicy=Local --set controller.metrics.enabled=true --set-string controller.podAnnotations.&quot;prometheus\.io/scrape&quot;=&quot;true&quot; --set-string controller.podAnnotations.&quot;prometheus\.io/port&quot;=&quot;10254&quot;  -f values.yaml</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef213601d2d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>