From 9731e4e698a1729530cf75e5ec930ac1ccf2c31a Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Mon, 1 Apr 2024 15:41:02 +0200 Subject: [PATCH 01/14] feat: add timezone information to the available fields --- Dockerfile | 6 ++++++ nginx/conf.d/geoip2.conf | 6 ++++++ nginx/conf.d/ipinfo.conf | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b00f5e3..18c5278 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,12 @@ RUN sed 's/GeoLite2-Country_[0-9]*.tar.gz/GeoLite2-Country.tar.gz/g' -i GeoLite2 RUN sha256sum -c GeoLite2-Country.tar.gz.sha256 RUN tar xvf GeoLite2-Country.tar.gz --strip 1 +RUN wget "${MAXMIND_BASE_URL}edition_id=GeoLite2-City&suffix=tar.gz" -O GeoLite2-City.tar.gz +RUN wget "${MAXMIND_BASE_URL}edition_id=GeoLite2-City&suffix=tar.gz.sha256" -O GeoLite2-City.tar.gz.sha256 +RUN sed 's/GeoLite2-City_[0-9]*.tar.gz/GeoLite2-City.tar.gz/g' -i GeoLite2-City.tar.gz.sha256 +RUN sha256sum -c GeoLite2-City.tar.gz.sha256 +RUN tar xvf GeoLite2-City.tar.gz --strip 1 + FROM alpine:3.23 as release LABEL name="ipinfo.tw" RUN mkdir -p /run/nginx/ /usr/share/GeoIP/ diff --git a/nginx/conf.d/geoip2.conf b/nginx/conf.d/geoip2.conf index 50051de..3dc5584 100644 --- a/nginx/conf.d/geoip2.conf +++ b/nginx/conf.d/geoip2.conf @@ -11,3 +11,9 @@ geoip2 /usr/share/GeoIP/GeoLite2-ASN.mmdb { $ip_aso source=$remote_addr autonomous_system_organization; $ip_as_build_epoch metadata build_epoch; } + +geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb { + auto_reload 1d; # Automatically reload the database daily + $ip_time_zone source=$remote_addr location time_zone; # Retrieve the time zone +} + diff --git a/nginx/conf.d/ipinfo.conf b/nginx/conf.d/ipinfo.conf index a21c46e..7eee71d 100644 --- a/nginx/conf.d/ipinfo.conf +++ b/nginx/conf.d/ipinfo.conf @@ -50,6 +50,9 @@ server { location = /user_agent { return 200 "$http_user_agent\n"; } + location = /timezone { + return 200 "$ip_time_zone\n"; + } location ~* ^/index.htm(l)?$ { rewrite ^(.*)$ /; } @@ -58,7 +61,7 @@ server { } location = /json { default_type application/json; - return 200 "{\"ip\":\"$remote_addr\",\"country_code\":\"$ip_country_code\",\"country_name\":\"$ip_country_name\",\"asn\":\"$ip_asn\",\"as_desc\":\"$ip_aso\",\"user_agent\":\"$http_user_agent\"}\n"; + return 200 "{\"ip\":\"$remote_addr\",\"country_code\":\"$ip_country_code\",\"country_name\":\"$ip_country_name\",\"timezone\":\"$ip_time_zone\",\"asn\":\"$ip_asn\",\"as_desc\":\"$ip_aso\",\"user_agent\":\"$http_user_agent\"}\n"; } location = /build_epoch { default_type application/json; From 50ea5f20a0040801d6866ba402d7faa6bc05a977 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Tue, 2 Apr 2024 15:43:16 +0200 Subject: [PATCH 02/14] chore: style updates --- nginx/conf.d/geoip2.conf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nginx/conf.d/geoip2.conf b/nginx/conf.d/geoip2.conf index 3dc5584..630fbd8 100644 --- a/nginx/conf.d/geoip2.conf +++ b/nginx/conf.d/geoip2.conf @@ -13,7 +13,6 @@ geoip2 /usr/share/GeoIP/GeoLite2-ASN.mmdb { } geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb { - auto_reload 1d; # Automatically reload the database daily - $ip_time_zone source=$remote_addr location time_zone; # Retrieve the time zone + auto_reload 1d; + $ip_time_zone source=$remote_addr location time_zone; } - From 59506b55b861df3e599a498abba082f1855bf3f0 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Tue, 2 Apr 2024 15:46:44 +0200 Subject: [PATCH 03/14] chore: added docs regarding the timezone field --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd17d1e..786c299 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,12 @@ Use any http(s) client to explore the server, e.g. https://ipinfo.tw, - `wget -qO- https://ipinfo.tw` - `curl https://ipinfo.tw` -Without any specified URI, the server will return IP address, country, AS, and user agent. +Without any specified URI, the server will return IP address, country, timezone, AS, and user agent. If you prefer to receive a machine-readable result, use path `/json` (without trailing slash), e.g. `https://ipinfo.tw/json`, the result will look like: ```json -{"ip":"3.115.123.234","country_code":"JP","country_name":"Japan","asn":"16509","as_desc":"Amazon.com, Inc.","user_agent":"curl/7.58.0"} +{"ip":"3.115.123.234","country_code":"JP","country_name":"Japan","timezone":"Asia/Tokyo","asn":"16509","as_desc":"Amazon.com, Inc.","user_agent":"curl/7.58.0"} ``` #### Endpoints @@ -75,6 +75,7 @@ You can also specify the following URI to retrieve certain info: - `asn`: AS number - `as_desc`: AS description - `user_agent`: User agent string +- `timezone`: Timezone based on the city (e.g Europe/Amsterdam) Examples: @@ -97,6 +98,9 @@ HK $ curl https://ipinfo.tw/country_name South Korea +$ curl https://ipinfo.tw/timezone +Europe/Amsterdam + $ curl https://ipinfo.tw/as AS16509 / Amazon.com, Inc. From 2637d67017cd8aae1bf2e33770203c5c45802cf7 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Tue, 2 Apr 2024 15:50:24 +0200 Subject: [PATCH 04/14] fixed the coderabbit spelling suggestions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 786c299..69b2d35 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ A self-hosted, non-tracking, and ad-free solution to reveal client-side IP info This project is also hosted publicly on https://ipinfo.tw, feel free to give it a try! -Please note that for response integrity and privacy concerns, this demo is behind an reverse proxy with https enabled, which is not part of this project. http traffic will be redirected to use https to establish the connection, in case the plaintext data being sniffed/intercepted. +Please note that for response integrity and privacy concerns, this demo is behind a reverse proxy with https enabled, which is not part of this project. HTTP traffic will be redirected to use https to establish the connection, in case the plaintext data being sniffed/intercepted. ## Usage @@ -46,7 +46,7 @@ Run the server daemon via docker: docker run -d --name ipinfo.tw -p 80:8080 peterdavehello/ipinfo.tw:latest ``` -If you want to put this container behind reverse proxy, set up an `X-Real-IP` header and pass the it to the container, so that it can use the header as the IP of the client. +If you want to put this container behind reverse proxy, set up an `X-Real-IP` header and pass it to the container, so that it can use the header as the IP of the client. ### Client side From 4dfc6a9d6df7580a2e853edbbd2bb21091ae0825 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Wed, 3 Apr 2024 09:09:58 +0200 Subject: [PATCH 05/14] Revert "fixed the coderabbit spelling suggestions" This reverts commit 8ca2ec0781527b83305cbad0b26a81e57187550e. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69b2d35..786c299 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ A self-hosted, non-tracking, and ad-free solution to reveal client-side IP info This project is also hosted publicly on https://ipinfo.tw, feel free to give it a try! -Please note that for response integrity and privacy concerns, this demo is behind a reverse proxy with https enabled, which is not part of this project. HTTP traffic will be redirected to use https to establish the connection, in case the plaintext data being sniffed/intercepted. +Please note that for response integrity and privacy concerns, this demo is behind an reverse proxy with https enabled, which is not part of this project. http traffic will be redirected to use https to establish the connection, in case the plaintext data being sniffed/intercepted. ## Usage @@ -46,7 +46,7 @@ Run the server daemon via docker: docker run -d --name ipinfo.tw -p 80:8080 peterdavehello/ipinfo.tw:latest ``` -If you want to put this container behind reverse proxy, set up an `X-Real-IP` header and pass it to the container, so that it can use the header as the IP of the client. +If you want to put this container behind reverse proxy, set up an `X-Real-IP` header and pass the it to the container, so that it can use the header as the IP of the client. ### Client side From ba579bec47dfab3f88dfb731a9d2dc5abc7b0a74 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Fri, 9 Jan 2026 10:42:35 -0400 Subject: [PATCH 06/14] k8s deployment files --- k8s/deployment.yaml | 39 +++++++++++++++++++++++++++++++++++++++ k8s/ingress.yaml | 29 +++++++++++++++++++++++++++++ k8s/service.yaml | 23 +++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 k8s/deployment.yaml create mode 100644 k8s/ingress.yaml create mode 100644 k8s/service.yaml diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000..dc25cdc --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: eva-whoami + name: eva-whoami + namespace: platform-tools +spec: + progressDeadlineSeconds: 600 + replicas: 2 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: eva-whoami + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: eva-whoami + spec: + containers: + - image: cratecache.azurecr.io/new-black/eva-whoami + imagePullPolicy: Always + name: whoami + ports: + - containerPort: 8080 + protocol: TCP + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 diff --git a/k8s/ingress.yaml b/k8s/ingress.yaml new file mode 100644 index 0000000..51397e6 --- /dev/null +++ b/k8s/ingress.yaml @@ -0,0 +1,29 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + cert-manager.io/acme-challenge-type: dns01 + cert-manager.io/cluster-issuer: letsencrypt-prod-dns + kubernetes.io/ingress.class: nginx + generation: 2 + labels: + name: eva-whoami + name: eva-whoami + namespace: platform-tools +spec: + ingressClassName: nginx + rules: + - host: whoami.on-eva.io + http: + paths: + - backend: + service: + name: eva-whoami + port: + number: 8080 + path: / + pathType: ImplementationSpecific + tls: + - hosts: + - whoami.on-eva.io + secretName: eva-whoami-tls diff --git a/k8s/service.yaml b/k8s/service.yaml new file mode 100644 index 0000000..157fb56 --- /dev/null +++ b/k8s/service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + service.beta.kubernetes.io/azure-load-balancer-resource-group: rg-prod-eva + labels: + component: eva-whoami + name: eva-whoami + namespace: platform-tools +spec: + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - name: whoami + nodePort: 31514 + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: eva-whoami + sessionAffinity: None + type: LoadBalancer From cbd7cc7fe447bdecbcbfcb1f0e4cbbc4d69e8da2 Mon Sep 17 00:00:00 2001 From: nb-rubenoost <86608623+nb-rubenoost@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:47:53 +0100 Subject: [PATCH 07/14] Add GitHub Actions build workflow configuration --- .github/build.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/build.yml diff --git a/.github/build.yml b/.github/build.yml new file mode 100644 index 0000000..30ce532 --- /dev/null +++ b/.github/build.yml @@ -0,0 +1,52 @@ +name: Build + +permissions: + contents: read + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + build: + name: Build & deploy + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 + + - name: Login to Docker Hub + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0 + with: + username: ${{ secrets.ACR_USERNAME }} + password: ${{ secrets.ACR_PASSWORD }} + registry: cratecache.azurecr.io/new-black + + # Switch to a different builder + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f #3.12.0 + + # Determine the run number + - name: Set the run number + id: commit-id + run: | + echo "build_number=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV + + # Build the production image + - name: Build production image + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 #v6.18.0 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + target: final + build_args: | + MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} + tags: | + cratecache.azurecr.io/new-black/eva-whoami:latest + cratecache.azurecr.io/new-black/eva-whoami:${{ env.build_number }} + builder: ${{ steps.buildx.outputs.name }} + images: | + cratecache.azurecr.io/new-black/henk2:${{ env.build_number }} From 3706e8e8486f550ccb2f04eab2a08428a786c8e6 Mon Sep 17 00:00:00 2001 From: Ruben Oost Date: Fri, 9 Jan 2026 15:50:58 +0100 Subject: [PATCH 08/14] move workflow to correct location --- .github/{ => workflows}/build.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/build.yml (100%) diff --git a/.github/build.yml b/.github/workflows/build.yml similarity index 100% rename from .github/build.yml rename to .github/workflows/build.yml From 72a67bcc308a3504b166f9efff826638850fb7a0 Mon Sep 17 00:00:00 2001 From: nb-rubenoost <86608623+nb-rubenoost@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:51:57 +0100 Subject: [PATCH 09/14] Change build target from 'final' to 'release' --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30ce532..733f5be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,7 +41,7 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - target: final + target: release build_args: | MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} tags: | From 1766a98ae64c0cb0e62c1a7962bfc592214ab2e1 Mon Sep 17 00:00:00 2001 From: Ruben Oost Date: Fri, 9 Jan 2026 16:12:29 +0100 Subject: [PATCH 10/14] zo dan --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 733f5be..bc38a6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,8 +42,7 @@ jobs: platforms: linux/amd64,linux/arm64 push: true target: release - build_args: | - MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} + build_args: MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} tags: | cratecache.azurecr.io/new-black/eva-whoami:latest cratecache.azurecr.io/new-black/eva-whoami:${{ env.build_number }} From 2a2e88a08a9fdab738eda89a1646dace99cb68ea Mon Sep 17 00:00:00 2001 From: Ruben Oost Date: Fri, 9 Jan 2026 16:13:25 +0100 Subject: [PATCH 11/14] of zo --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc38a6c..733f5be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,8 @@ jobs: platforms: linux/amd64,linux/arm64 push: true target: release - build_args: MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} + build_args: | + MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} tags: | cratecache.azurecr.io/new-black/eva-whoami:latest cratecache.azurecr.io/new-black/eva-whoami:${{ env.build_number }} From a337c02313861d7dba29bc929274156f92bba921 Mon Sep 17 00:00:00 2001 From: Ruben Oost Date: Fri, 9 Jan 2026 16:14:46 +0100 Subject: [PATCH 12/14] dus --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 733f5be..ecfa20e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,5 @@ name: Build -permissions: - contents: read - on: workflow_dispatch: push: From 56b5625223b779bffa5a1ddc6f34a4e22e94426c Mon Sep 17 00:00:00 2001 From: Ruben Oost Date: Fri, 9 Jan 2026 16:15:39 +0100 Subject: [PATCH 13/14] dit zou moeten werken --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ecfa20e..6778b85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,11 +39,9 @@ jobs: platforms: linux/amd64,linux/arm64 push: true target: release - build_args: | + build-args: | MAXMIND_LICENSE_KEY=${{ secrets.MAXMIND_LICENSE_KEY }} tags: | cratecache.azurecr.io/new-black/eva-whoami:latest cratecache.azurecr.io/new-black/eva-whoami:${{ env.build_number }} builder: ${{ steps.buildx.outputs.name }} - images: | - cratecache.azurecr.io/new-black/henk2:${{ env.build_number }} From 9781a8d95a051d5cd9ee806721d0b0172a6ae6e3 Mon Sep 17 00:00:00 2001 From: Mark Gerrits Date: Fri, 15 May 2026 11:22:05 -0400 Subject: [PATCH 14/14] use the fwd for header --- nginx/conf.d/realip.conf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nginx/conf.d/realip.conf b/nginx/conf.d/realip.conf index 7ab572d..906263a 100644 --- a/nginx/conf.d/realip.conf +++ b/nginx/conf.d/realip.conf @@ -1,4 +1,5 @@ -real_ip_header X-Real-IP; -set_real_ip_from 10.0.0.0/8; -set_real_ip_from 172.16.0.0/12; -set_real_ip_from 192.168.0.0/16; +real_ip_header X-Forwarded-For; +real_ip_recursive on; +set_real_ip_from 10.0.0.0/8; +set_real_ip_from 172.16.0.0/12; +set_real_ip_from 192.168.0.0/16; \ No newline at end of file