From dc10d87e3f7409c4a8663363492ffb66f6e1f631 Mon Sep 17 00:00:00 2001 From: shenlan Date: Mon, 18 Aug 2025 15:53:32 +0800 Subject: [PATCH] feat: use V2Fly GeoIP data for OpenResty --- playbooks/roles/vhosts/OpenResty/tasks/main.yml | 13 +++---------- .../vhosts/OpenResty/templates/geo_redirect.conf.j2 | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/playbooks/roles/vhosts/OpenResty/tasks/main.yml b/playbooks/roles/vhosts/OpenResty/tasks/main.yml index e5f6c82..aede025 100644 --- a/playbooks/roles/vhosts/OpenResty/tasks/main.yml +++ b/playbooks/roles/vhosts/OpenResty/tasks/main.yml @@ -46,19 +46,12 @@ mode: "0755" # yamllint disable rule:line-length -- name: Download GeoLite2 Country database +- name: Download V2Fly GeoIP database get_url: - url: https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz - dest: /usr/share/GeoIP/GeoLite2-Country.mmdb.gz + url: https://github.com/v2fly/geoip/releases/latest/download/geoip.dat + dest: /usr/share/GeoIP/geoip.dat # yamllint enable rule:line-length -- name: Decompress GeoLite2 Country database - unarchive: - src: /usr/share/GeoIP/GeoLite2-Country.mmdb.gz - dest: /usr/share/GeoIP/ - remote_src: true - creates: /usr/share/GeoIP/GeoLite2-Country.mmdb - - name: Ensure sites-available directory exists file: path: /usr/local/openresty/nginx/conf/sites-available diff --git a/playbooks/roles/vhosts/OpenResty/templates/geo_redirect.conf.j2 b/playbooks/roles/vhosts/OpenResty/templates/geo_redirect.conf.j2 index 887470b..1196452 100644 --- a/playbooks/roles/vhosts/OpenResty/templates/geo_redirect.conf.j2 +++ b/playbooks/roles/vhosts/OpenResty/templates/geo_redirect.conf.j2 @@ -17,7 +17,7 @@ server { end local geoip = require("resty.maxminddb") - local reader, err = geoip.new("/usr/share/GeoIP/GeoLite2-Country.mmdb") + local reader, err = geoip.new("/usr/share/GeoIP/geoip.dat") if not reader then ngx.log(ngx.ERR, "failed to open MaxMind DB: ", err) ngx.header["Set-Cookie"] = "region=GLOBAL; Path=/; Max-Age=3600"