{"id":16767869,"url":"https://github.com/eolinker/goku-plugin-ip_restriction","last_synced_at":"2025-04-10T19:21:15.334Z","repository":{"id":103579801,"uuid":"209018309","full_name":"eolinker/Goku-plugin-ip_restriction","owner":"eolinker","description":"GOKU API GATEWAY 官方插件：IP黑白名单","archived":false,"fork":false,"pushed_at":"2019-09-19T02:27:28.000Z","size":11,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:01:37.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eolinker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-17T09:52:54.000Z","updated_at":"2023-07-25T14:29:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"1349a2f7-0122-487a-886a-e30824735c37","html_url":"https://github.com/eolinker/Goku-plugin-ip_restriction","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-ip_restriction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-ip_restriction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-ip_restriction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-ip_restriction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eolinker","download_url":"https://codeload.github.com/eolinker/Goku-plugin-ip_restriction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281382,"owners_count":21077423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T06:10:09.832Z","updated_at":"2025-04-10T19:21:15.323Z","avatar_url":"https://github.com/eolinker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goku Plugin：IP Restriction\n\n| 插件名称  | 文件名.so |  插件类型  | 错误处理方式 | 作用范围 |  优先级  |\n| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |\n| IP黑白名单  | goku-ip_restriction | 访问策略 | 继续后续操作 | 转发前  | 990 |\n\nIP黑名单指除黑名单外的IP均可访问，IP白名单指除白名单外的IP不能访问，网关通过会 **X-Real-IP** 头判断客户端真实IP。\n\n##### 一、IP配置支持以下写法：\n（1）192.168.0.1\n（2）192.168.0.1/26\n（3）192.168.0.*\n\n注：\\*仅支持放最后一位，如：192.\\*、192.168.\\*、192.168.0.\\*\n\n##### 二、配合nginx的X-Real-IP使用：\n（1）若客户端与网关之间不存在代理服务器，此时从请求中解析出的IP地址就是实际客户端的IP，网关会把该地址设为X-Real-IP头的值；\n（2）若客户端与网关之间存在多层代理，则需在 **第一层代理** 中设置X-Real-IP请求头，此时网关会把代理传来的X-Real-IP转发到服务器。\n\n**代理配置示例**：\n```\nlocation / {\n\troot   html;\n\tindex  index.html index.htm index.php;\n\tproxy_set_header X-Real-IP $remote_addr;\n\tproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\tproxy_pass http://192.168.247.132;\n\t}\n```\n\n# 目录\n\n- [编译教程](#编译教程 \"编译教程\")\n- [安装教程](#安装教程 \"安装教程\")\n- [使用教程](#使用教程 \"使用教程\")\n- [更新日志](#更新日志 \"更新日志\")\n\n# 编译教程\n\n#### 环境要求\n* 系统：基于 Linux 内核（2.6.23+）的系统，CentOS、RedHat 等均可；\n\n* golang版本号：12.x及其以上\n\n* 环境变量设置：\n\t* GO111MODULE：on\n\t\n\t* GOPROXY：https://goproxy.io\n\n\n#### 编译步骤\n\n1.clone项目\n\n2.进入项目文件夹，执行**build.sh**\n```\ncd goku-ip_restriction \u0026\u0026 chmod +x build.sh \u0026\u0026 ./build.sh\n```\n\n###### 注：build.sh为通用的插件编译脚本，自定义插件时可以拷贝直接使用。\n\n3.执行第2步将会生成文件： **{插件名}.so**\n\n将该文件上传到**节点服务器运行目录**下的**plugin**文件夹，然后在控制台安装插件即可使用。\n\n# 安装教程\n前往 Goku API Gateway 官方网站查看：[插件安装教程](url \"https://help.eolinker.com/#/tutorial/?groupID=c-341\u0026productID=19\")\n\n# 使用教程\n\n#### 配置页面\n\n进入控制台 \u003e\u003e 策略管理 \u003e\u003e 某策略 \u003e\u003e 策略插件 \u003e\u003e IP黑白名单插件：\n\n![](http://data.eolinker.com/course/rrwbADA8d86ccce880127198916f0b0306250ecacb002e0)\n\n#### 配置参数\n\n| 参数名 | 说明   |  值可能性\n| ------------ | ------------ |  ------------ |  \n|  ipListType | IP名单类型| white/black/none  | \n| ipWhiteList  | IP白名单列表 |   |\n| ipBlackList  | IP黑名单列表 |  |  |\n\n#### 配置示例\n\n```\n{\n    \"ipListType\":\"black\",\n    \"ipWhiteList\":[\"127.0.0.1\"],\n    \"ipBlackList\":[\"127.0.0.2\"]\n}\n```\n\n#### ### 返回示例\n\n```\n\tHTTP/1.1 403 Forbidden\n\tContent-Type: text/plain\n\tContent-Length: 18\n\n\t[ERROR]Illegal IP!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feolinker%2Fgoku-plugin-ip_restriction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feolinker%2Fgoku-plugin-ip_restriction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feolinker%2Fgoku-plugin-ip_restriction/lists"}