Comments (2)
http {
geoip_country /path/to/GeoIP/GeoIP.dat;
server {
listen 80;
server_name your_domain.com;
location / {
# 检查访问者国家,只允许**(CN)访问和特定 IP 地址(1.1.1.1)
if ($geoip_country_code != CN) {
if ($remote_addr != 18.163.177.7) {
return 403;
}
}
# 其他配置
}
}
}
from geoip.
本项目中的 dat 格式 geoip 文件是 V2Ray 专属的,不能用于 Nginx。
Nginx 中的 dat 格式 geoip 数据库来源于 MaxMind,但这个格式已经被 MaxMind 列为过时,MaxMind 现在推荐使用 mmdb 格式。本项目中的 mmdb 格式文件理论上可用于 Nginx,但我没有尝试过,代码中只保留了一个变量 iso_code
(两位字母的国家代号) 。
在 Nginx 中使用 mmdb 格式 geoip 文件,可以参考:https://github.com/leev/ngx_http_geoip2_module
另外,对于 IP / CIDR 的简单访问控制,也可以使用 Nginx 的 allow
和 deny
,参考:https://github.com/Loyalsoldier/geoip/tree/release/nginx
from geoip.
Related Issues (20)
- geoip:bigo HOT 1
- 为什么自己添加 IP 源后生成会被自动修改或删除很多 IP 段? HOT 10
- 应从现有国家分类中剔除全球任播IP段 HOT 2
- Netflix的GEOSITE比GEOIP要完整吗 HOT 1
- 请问可以考虑支持db-ip的数据库吗? HOT 6
- 请求添加 GCORE AS199524 AS202422 HOT 1
- Please support sing-box srs format officially required in singbox 1.8.0+. HOT 2
- 部分IP同时存在于HK和CN中,但合并后只在HK中 HOT 1
- 请求更改geoip:private的名称 HOT 1
- 202402290055 HK好多都显示CN HOT 2
- 能单独生成一个!cn的ip集吗?应该怎么做? HOT 2
- 单独的IPv6 geoip文件 HOT 1
- 能考虑增加geoip:tor吗?这个也算非常有意义的吧 HOT 1
- geoip:cn 会导致一些*.TW域名直连 HOT 1
- v2ray 的protobuf文件好像更新了,我目前用v2ray的protobuf解析不了 HOT 8
- whatsapp HOT 1
- Required: GEOIP: Tencent HOT 1
- dat格式可以在ngx_http_geoip_module模块使用吗? HOT 4
- GEOIP能否按洲归类 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geoip.