We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问nginx能用吗,我想用来判断国家
The text was updated successfully, but these errors were encountered:
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; } } # 其他配置 } } }
Sorry, something went wrong.
本项目中的 dat 格式 geoip 文件是 V2Ray 专属的,不能用于 Nginx。
Nginx 中的 dat 格式 geoip 数据库来源于 MaxMind,但这个格式已经被 MaxMind 列为过时,MaxMind 现在推荐使用 mmdb 格式。本项目中的 mmdb 格式文件理论上可用于 Nginx,但我没有尝试过,代码中只保留了一个变量 iso_code(两位字母的国家代号) 。
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
allow
deny
No branches or pull requests
请问nginx能用吗,我想用来判断国家
The text was updated successfully, but these errors were encountered: