feat: use V2Fly GeoIP data for OpenResty
This commit is contained in:
parent
dc1fe4d079
commit
dc10d87e3f
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user