{"id":50901582,"url":"https://github.com/flytrap/test-ip","last_synced_at":"2026-06-16T03:04:30.684Z","repository":{"id":359046895,"uuid":"807514203","full_name":"flytrap/test-ip","owner":"flytrap","description":"测试k8s中 真实ip是否可以获取","archived":false,"fork":false,"pushed_at":"2026-05-20T05:55:49.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-20T09:22:52.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go Template","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/flytrap.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-29T08:45:26.000Z","updated_at":"2026-05-20T05:55:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/flytrap/test-ip","commit_stats":null,"previous_names":["flytrap/test-ip"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/flytrap/test-ip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flytrap%2Ftest-ip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flytrap%2Ftest-ip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flytrap%2Ftest-ip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flytrap%2Ftest-ip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flytrap","download_url":"https://codeload.github.com/flytrap/test-ip/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flytrap%2Ftest-ip/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34388678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2026-06-16T03:04:29.350Z","updated_at":"2026-06-16T03:04:30.676Z","avatar_url":"https://github.com/flytrap.png","language":"Go Template","funding_links":[],"categories":[],"sub_categories":[],"readme":"# test-ip\n\n测试 Kubernetes 中真实 IP 是否可以获取。\n\n## 功能\n\n获取客户端真实 IP 和请求头信息，用于验证网关代理（如 Istio IngressGateway）是否正确传递客户端请求信息。\n\n## API\n\n### GET /test/ip\n\n获取客户端真实 IP 地址。\n\n```bash\ncurl -H \"Host: ok.com\" http://\u003cingress-gateway\u003e/test/ip\n```\n\n响应示例：\n```json\n{\n  \"ip\": \"192.168.1.100\"\n}\n```\n\n### GET /test/header\n\n获取请求头信息。\n\n```bash\ncurl -H \"Host: ok.com\" http://\u003cingress-gateway\u003e/test/header\n```\n\n响应示例：\n```json\n{\n  \"Accept\": \"*/*\",\n  \"Host\": \"ok.com\",\n  \"X-Real-IP\": \"192.168.1.100\",\n  ...\n}\n```\n\n## 部署\n\n### 1. 构建镜像\n\n```bash\ndocker build -t test-ip:latest .\n```\n\n### 2. 部署应用\n\n```bash\nkubectl apply -f deployment.yaml\n```\n\n这会创建 Deployment 和 Service 资源。\n\n### 3. 部署 Istio 网关配置\n\n```bash\nkubectl apply -f gateway.yaml\n```\n\n这会创建 Gateway 和 VirtualService 资源，将 `ok.com` 域名的流量路由到你的 test-ip 服务。\n\n### 4. 访问服务\n\n通过 Istio IngressGateway 域名 `ok.com` 访问服务。\n\n## Istio 配置\n\n- **Gateway**: `test-gateway` - 监听 80 端口，接收 `ok.com` 域名流量\n- **VirtualService**: `test-vs` - 将流量路由到 `test-ip` 服务的 8080 端口\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflytrap%2Ftest-ip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflytrap%2Ftest-ip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflytrap%2Ftest-ip/lists"}