{"id":20719700,"url":"https://github.com/slince/spike","last_synced_at":"2025-04-12T14:55:26.392Z","repository":{"id":48628241,"uuid":"94964010","full_name":"slince/spike","owner":"slince","description":":mega: A fast reverse proxy written in PHP that helps to expose local services to the internet","archived":false,"fork":false,"pushed_at":"2021-10-25T16:47:55.000Z","size":720,"stargazers_count":669,"open_issues_count":5,"forks_count":119,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-04-03T13:18:35.892Z","etag":null,"topics":["expose-localhost","http-tunnel","nat","proxy","reverse-proxy","spike","tcp-tunnel","tunnel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slince.png","metadata":{"files":{"readme":"README-zh_CN.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-21T04:50:33.000Z","updated_at":"2025-03-06T08:18:33.000Z","dependencies_parsed_at":"2022-09-03T08:32:08.061Z","dependency_job_id":null,"html_url":"https://github.com/slince/spike","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fspike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fspike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fspike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fspike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slince","download_url":"https://codeload.github.com/slince/spike/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586243,"owners_count":21128995,"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":["expose-localhost","http-tunnel","nat","proxy","reverse-proxy","spike","tcp-tunnel","tunnel"],"created_at":"2024-11-17T03:18:04.653Z","updated_at":"2025-04-12T14:55:26.365Z","avatar_url":"https://github.com/slince.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/slince/spike/master/resources/logo.png\" width=\"200\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"LICENSE\" target=\"_blank\"\u003e\n        \u003cimg alt=\"Software License\" src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://travis-ci.org/slince/spike\"\u003e\n        \u003cimg src=\"https://img.shields.io/travis/slince/spike/master.svg?style=flat-square\" alt=\"Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/github/slince/spike\"\u003e\n        \u003cimg src=\"https://img.shields.io/codecov/c/github/slince/spike.svg?style=flat-square\" alt=\"Coverage Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/slince/spike\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/v/slince/spike.svg?style=flat-square\u0026amp;label=stable\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/slince/spike/?branch=master\"\u003e\n        \u003cimg src=\"https://img.shields.io/scrutinizer/g/slince/spike.svg?style=flat-square\" alt=\"Scrutinizer\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nSpike是一个可以用来将你的内网服务暴露在公网的快速的反向代理，基于[ReactPHP](https://github.com/reactphp)，采用IO多路复用模型。\n\n## 安装\n\n通过 composer 安装\n\n```bash\ncomposer global require slince/spike\n```\n\n\u003e 服务器与本地都需要执行此命令安装\n\n\n## 原理图\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/slince/spike/master/resources/diagram.png\"/\u003e\n\u003c/p\u003e\n\n## 配置服务端\n\n使用Spike的前提是你需要有一台公网可访问的机器，这里假设你已经有一台机器.你可以使用下面两种方式开启服务端。\n\n### 基于默认参数\n\n执行下面命令以开启服务\n\n```bash\n$ spiked --address=127.0.0.1:8088\n```\n上述命令可以创建一个基本服务，如果你需要定制更多信息可以基于配置文件服务\n\n\n### 基于配置文件\n\n- 初始化一个配置文件 \n\n执行下面命令创建文件\n\n```bash\n$ spiked init --dir=/home/conf --format=json\n```\n\n支持yaml,xml,ini,json四种格式的配置文件，默认使用json，使用下面命令查看帮助\n\n```bash\n$ spiked init -h\n```\n\n- 打开配置文件，修改相关参数\n\n- 基于配置文件开启服务\n \n```bash\n $ spiked --config=/home/conf/spiked.json\n```\n\n## 配置本地客户端\n\n开启客户端需要先创建配置文件\n\n- 初始化一个配置文件 \n\n执行下面命令创建文件\n\n```bash\n$ spike init --dir=/home/conf --format=json\n```\n\n使用下面命令查看帮助\n\n```bash\n$ spike init -h\n```\n\n- 打开配置文件，修改相关参数\n\n- 基于配置文件开启服务\n \n```bash\n$ spike --config=/home/conf/spike.json\n```\n\n\n## 定义隧道\n\n隧道的定义只在客户端，服务端不需要做任何配置，从而达到最简化配置。\n\n\u003e 目前支持http与tcp两种隧道\n\n打开本地配置文件\"spike.json\", 修改tunnel一项;\n\n- 添加http隧道\n\n```json\n{\n    \"protocol\": \"http\",\n    \"serverPort\": 8086,\n    \"proxyHosts\": {\n        \"www.foo.com\": \"127.0.0.1:80\",\n        \"www.bar.com\": \"192.168.1.101:8080\"\n    }\n}\n```\n启动客户端，访问 \"http://www.foo.com:8086\" , 服务将会被代理到本地\"127.0.0.1:80\"; 注意此处需要把 \"www.foo.com\" 解析到服务端所在机器上\n\n- 添加tcp隧道\n\n基于tcp协议的应用层协议都可使用本隧道代理，如：mysql,redis,ssh...等；下面是代理mysql服务的例子\n\n```json\n{\n    \"protocol\": \"tcp\",\n    \"serverPort\": 8087,\n    \"host\": \"127.0.0.1:3306\"\n}\n```\n执行下面命令访问本地mysql服务：\n\n```bash\n$ mysql -h 服务器地址 -P 8087\n```\n\n## 客户端身份认证\n\n基于默认参数开启的服务端没有开启客户端身份认证服务，如果需要开启该服务则只能基于配置文件去启动服务端. \n\n- 服务端启用认证服务\n\n打开\"spiked.json\"文件，修改auth一项信息，然后重启服务\n\n\u003e 目前只支持简单的用户名密码认证方式，更多的认证方式后面会陆续加入.\n\n- 修改客户端身份信息\n\n打开本地\"spike.json\"文件，修改auth一栏信息，与服务端配置保持一致即可\n\n\n## 日志配置\n\n默认开启屏幕输出与文件两种形式的日志；前者会打印到控制台；后者会写入到指定文件；默认日志等级是\"info\"，此项信息可以通过\n修改配置文件\"log\"一项调整；\n\n## 查看所有命令\n\n```bash\n$ spike list\n   _____   _____   _   _   _    _____\n  /  ___/ |  _  \\ | | | | / /  | ____|\n  | |___  | |_| | | | | |/ /   | |__\n  \\___  \\ |  ___/ | | | |\\ \\   |  __|\n   ___| | | |     | | | | \\ \\  | |___\n  /_____/ |_|     |_| |_|  \\_\\ |_____|\n  \n  Spike Client 0.0.1\n  \n  Usage:\n    command [options] [arguments]\n  \n  Options:\n    -h, --help            Display this help message\n    -q, --quiet           Do not output any message\n    -V, --version         Display this application version\n        --ansi            Force ANSI output\n        --no-ansi         Disable ANSI output\n    -n, --no-interaction  Do not ask any interactive question\n    -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug\n  \n  Available commands:\n    help        Displays help for a command\n    init        Create a configuration file in the specified directory\n    list        Lists commands\n    list-proxy  Lists all supported proxy hosts by the client\n```\n\n## Changelog\n\n查看 [CHANGELOG.md](./CHANGELOG.md)\n\n## License\n \nThe MIT license. See [MIT](https://opensource.org/licenses/MIT)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fspike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslince%2Fspike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fspike/lists"}