1 Star 4 Fork 1

微凉/spike

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
CC0-1.0

Software License Build Status Coverage Status Latest Stable Version Scrutinizer

Spike是一个可以用来将你的内网服务暴露在公网的快速的反向代理,基于ReactPHP,采用IO多路复用模型。

安装

通过 composer 安装

composer global require slince/spike

服务器与本地都需要执行此命令安装

原理图

配置服务端

使用Spike的前提是你需要有一台公网可访问的机器,这里假设你已经有一台机器.你可以使用下面两种方式开启服务端。

基于默认参数

执行下面命令以开启服务

$ spiked --address=127.0.0.1:8088

上述命令可以创建一个基本服务,如果你需要定制更多信息可以基于配置文件服务

基于配置文件

  • 初始化一个配置文件

执行下面命令创建文件

$ spiked init --dir=/home/conf --format=json

支持yaml,xml,ini,json四种格式的配置文件,默认使用json,使用下面命令查看帮助

$ spiked init -h
  • 打开配置文件,修改相关参数

  • 基于配置文件开启服务

 $ spiked --config=/home/conf/spiked.json

配置本地客户端

开启客户端需要先创建配置文件

  • 初始化一个配置文件

执行下面命令创建文件

$ spike init --dir=/home/conf --format=json

使用下面命令查看帮助

$ spike init -h
  • 打开配置文件,修改相关参数

  • 基于配置文件开启服务

$ spike --config=/home/conf/spike.json

定义隧道

隧道的定义只在客户端,服务端不需要做任何配置,从而达到最简化配置。

目前支持http与tcp两种隧道

打开本地配置文件"spike.json", 修改tunnel一项;

  • 添加http隧道
{
    "protocol": "http",
    "serverPort": 8086,
    "proxyHosts": {
        "www.foo.com": "127.0.0.1:80",
        "www.bar.com": "192.168.1.101:8080"
    }
}

启动客户端,访问 "http://www.foo.com:8086" , 服务将会被代理到本地"127.0.0.1:80"; 注意此处需要把 "www.foo.com" 解析到服务端所在机器上

  • 添加tcp隧道

基于tcp协议的应用层协议都可使用本隧道代理,如:mysql,redis,ssh...等;下面是代理mysql服务的例子

{
    "protocol": "tcp",
    "serverPort": 8087,
    "host": "127.0.0.1:3306"
}

执行下面命令访问本地mysql服务:

$ mysql -h 服务器地址 -P 8087

客户端身份认证

基于默认参数开启的服务端没有开启客户端身份认证服务,如果需要开启该服务则只能基于配置文件去启动服务端.

  • 服务端启用认证服务

打开"spiked.json"文件,修改auth一项信息,然后重启服务

目前只支持简单的用户名密码认证方式,更多的认证方式后面会陆续加入.

  • 修改客户端身份信息

打开本地"spike.json"文件,修改auth一栏信息,与服务端配置保持一致即可

日志配置

默认开启屏幕输出与文件两种形式的日志;前者会打印到控制台;后者会写入到指定文件;默认日志等级是"info",此项信息可以通过 修改配置文件"log"一项调整;

查看所有命令

$ spike list
   _____   _____   _   _   _    _____
  /  ___/ |  _  \ | | | | / /  | ____|
  | |___  | |_| | | | | |/ /   | |__
  \___  \ |  ___/ | | | |\ \   |  __|
   ___| | | |     | | | | \ \  | |___
  /_____/ |_|     |_| |_|  \_\ |_____|
  
  Spike Client 0.0.1
  
  Usage:
    command [options] [arguments]
  
  Options:
    -h, --help            Display this help message
    -q, --quiet           Do not output any message
    -V, --version         Display this application version
        --ansi            Force ANSI output
        --no-ansi         Disable ANSI output
    -n, --no-interaction  Do not ask any interactive question
    -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  
  Available commands:
    help        Displays help for a command
    init        Create a configuration file in the specified directory
    list        Lists commands
    list-proxy  Lists all supported proxy hosts by the client

Changelog

查看 CHANGELOG.md

License

The MIT license. See MIT

<p align="center"> <img src="https://raw.githubusercontent.com/slince/spike/master/resources/logo.png" width="200"/> </p> <p align="center"> <a href="LICENSE" target="_blank"> <img alt="Software License" src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square"> </a> <a href="https://travis-ci.org/slince/spike"> <img src="https://img.shields.io/travis/slince/spike/master.svg?style=flat-square" alt="Build Status"> </a> <a href="https://codecov.io/github/slince/spike"> <img src="https://img.shields.io/codecov/c/github/slince/spike.svg?style=flat-square" alt="Coverage Status"> </a> <a href="https://packagist.org/packages/slince/spike"> <img src="https://img.shields.io/packagist/v/slince/spike.svg?style=flat-square&amp;label=stable" alt="Latest Stable Version"> </a> <a href="https://scrutinizer-ci.com/g/slince/spike/?branch=master"> <img src="https://img.shields.io/scrutinizer/g/slince/spike.svg?style=flat-square" alt="Scrutinizer"> </a> </p> Spike is a fast reverse proxy built on top of [ReactPHP](https://github.com/reactphp) that helps to expose your local services to the internet. [简体中文](./README-zh_CN.md) ## Installation Install via composer ```bash composer global require slince/spike ``` > Both the server and local machine need to install this. ## Schematic diagram <p align="center"> <img src="https://raw.githubusercontent.com/slince/spike/master/resources/diagram.png"/> </p> ## Configure the server A public machine that can be accessed on the internet is needed. Assuming already. There are two ways to start the server ### Based on defaults Use the following command to start the server ```bash $ spiked --address=127.0.0.1:8088 ``` The above command can create a basic service. If you want to customize more information, you should start the server based on the configuration file. ### Based on the configuration file. - Creates a configuration file Execute the following command to create it. ```bash $ spiked init --dir=/home/conf --format=json ``` Yaml,Xml,Ini and Json(default) files are supported. Use the following command for help. ```bash $ spiked init -h ``` - Open the configuration file and modify the parameters. - Executes the following command to start the service. ```bash $ spiked --config=/home/conf/spiked.json ``` ## Configure the client. You should first create a configuration file for the client. - Execute the following command to create it ```bash $ spike init --dir=/home/conf --format=json ``` Use the following command for help about this command ```bash $ spike init -h ``` - Open the configuration file and modify the parameters. - Start the client service. ```bash $ spike --config=/home/conf/spike.json ``` ## Tunnel The definition of the tunnel only in the client, the server does not need to do any configuration, so as to achieve the most simplified configuration. > Now supports both http and tcp tunnels Open the configuration file for the client and modify the parameters for "tunnel". - Add an HTTP tunnel ```json { "protocol": "http", "serverPort": 8086, "proxyHosts": { "www.foo.com": "127.0.0.1:80", "www.bar.com": "192.168.1.101:8080" } } ``` Restarts the client service. Visit "http://www.foo.com:8086", the service will be forwarded to the local "127.0.0.1:80"; Note that resolve "www.foo.com" to the server IP. - Add a TCP tunnel The services based on the tcp can use the tunnel, such as: mysql, redis, ssh and so on; The following is an example of proxy mysql service ```json { "protocol": "tcp", "serverPort": 8087, "host": "127.0.0.1:3306" } ``` Execute the following command to visit the local mysql service. ```bash $ mysql -h SERVER IP -P 8087 ``` ## Client authentication The authentication is not enabled on the server based on defaults.You should start the server based on configuration file, if you want to enable this. - Enable authentication Open the configuration file for the server and modify parameters for "auth" and restart the service. > Currently only supports a simple user name password authentication, more authentication methods will be added later. - Modify the client identity information Open the configuration file for the client and modify parameters for "auth". Keep the same parameters as the server. ## Configure log The default to open the console and file two forms of the log; the first will print the logs to the console; the second will write all the logs to the specified file; Default log level is "info"; You can adjust this in the configuration file. ## List Commands ```bash $ spike list _____ _____ _ _ _ _____ / ___/ | _ \ | | | | / / | ____| | |___ | |_| | | | | |/ / | |__ \___ \ | ___/ | | | |\ \ | __| ___| | | | | | | | \ \ | |___ /_____/ |_| |_| |_| \_\ |_____| Spike Client 0.0.1 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: help Displays help for a command init Create a configuration file in the specified directory list Lists commands list-proxy Lists all supported proxy hosts by the client ``` ## Changelog See [CHANGELOG.md](./CHANGELOG.md) ## License The MIT license. See [MIT](https://opensource.org/licenses/MIT)

简介

这个是我从GitHub上面找到的一款Php开发的内网穿透,极简配置,安装简单,只需要php即可运行,相关问题请咨询原版作者。此处仅仅作为收藏备份。 运行请自行检查spike.json里面的端口是否一致 原版:https://github.com/slince/spike 展开 收起
PHP
CC0-1.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/iteu/spike.git
git@gitee.com:iteu/spike.git
iteu
spike
spike
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891