Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet.

Overview

Software License Build Status Coverage Status Latest Stable Version Scrutinizer

Spike is a fast reverse proxy built on top of ReactPHP that helps to expose your local services to the internet.

简体中文

Installation

Install via composer

composer global require slince/spike

Both the server and local machine need to install this.

Schematic diagram

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

$ 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.

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

Yaml,Xml,Ini and Json(default) files are supported. Use the following command for help.

$ spiked init -h
  • Open the configuration file and modify the parameters.

  • Executes the following command to start the service.

 $ 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
$ spike init --dir=/home/conf --format=json

Use the following command for help about this command

$ spike init -h
  • Open the configuration file and modify the parameters.

  • Start the client service.

$ 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
{
    "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

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

Execute the following command to visit the local mysql service.

$ 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

$ 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

License

The MIT license. See MIT

Comments
  • server端运行报错

    server端运行报错

    image

    [2018-06-05 14:07:13] INFO: The server is running ...
    PHP Fatal error:  Uncaught TypeError: Argument 2 passed to Spike\Timer\Timer::activate() must be an instance of React\EventLoop\Timer\TimerInterface, instance of React\EventLoop\Timer\Timer given, called in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/UseTimerTrait.php on line 29 and defined in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/Timer.php:26
    Stack trace:
    #0 /home/deploy/.config/composer/vendor/slince/spike/src/Timer/UseTimerTrait.php(29): Spike\Timer\Timer->activate(Object(React\EventLoop\StreamSelectLoop), Object(React\EventLoop\Timer\Timer))
    #1 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Server.php(120): Spike\Server\Server->addTimer(Object(Spike\Server\Timer\ReviewClient))
    #2 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Application.php(93): Spike\Server\Server->run()
    #3 /home/deploy/.config/composer/vendor/slince/spike/src/Server/Application.php(79): Spike\Server\Application->runServer()
    #4 /home/deploy/.config/composer/vendor/slince/spike/src/Server/A in /home/deploy/.config/composer/vendor/slince/spike/src/Timer/Timer.php on line 26
    

    php版本

    [deploy@code-1000 ~]$ php -v
    PHP 7.0.29 (cli) (built: Apr  1 2018 00:08:23) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.0.29, Copyright (c) 1999-2017, by Zend Technologies
    
    enhancement 
    opened by wujunze 7
  • 虚拟主机安装spike

    虚拟主机安装spike

    阿里云的云虚拟主机控制台 https://help.aliyun.com/knowledge_detail/36152.html?spm=a2c4g.11186631.2.1.yjIAC4 阿里云的FTP服务 https://help.aliyun.com/knowledge_detail/36241.html?spm=a2c4g.11186631.2.1.aIE3rg

    1. 求教 —— spike使用的环境要求仅是PHP运行环境吗?
    2. 求教 —— 仅有一个PHP运行环境想要运行spike是需要写一个安装的PHP程序吗?
    opened by ghost 5
  • 如果禁用了两个函数。服务启动不起来

    如果禁用了两个函数。服务启动不起来

    如果禁用函数proc_open和stream_socket_server两个函数将会报错(默认lnmp是禁用的)

    PHP Warning: stream_set_blocking() expects parameter 1 to be resource, null given in /root/.config/composer/vendor/react/socket/src/TcpServer.php on line 166 [2018-08-17 17:43:18] INFO: The server is running ... [2018-08-17 17:43:48] INFO: Client Total: 0; Chunk Server Total: 0 [2018-08-17 17:44:18] INFO: Memory usage: 2523784

    但是服务并没有起来。建议添加这两个函数的禁用情况进行异常处理。

    解决办法:修复php.ini将这两个函数启用。

    opened by cryhac 4
  • 服务端启动成功  客户端连不上

    服务端启动成功 客户端连不上

    服务端启动成功 客户端连不上

    用namp检查了端口是开放的

    客户端报错

    $ spike --config=./spike_conf/spike.json -vvv                                                                            [20:08:15]
    [2018-06-05 20:08:21] INFO: The client is running ...
    [2018-06-05 20:08:21] ERROR: Cannot connect to the server. the server may not be available
    
    opened by wujunze 2
  • Http可用,TCP不可用

    Http可用,TCP不可用

    在使用Http 穿透的时候,一切都正常。 在使用tcp穿透都时候,始终是连接中,日志也显示正常,但是始终连接不上。

    测试过3306连接mysql,也测试过3389连接windows远程,均无法连接,一直显示连接中。

    服务端:centos 客户端:macos

    备注:代理端口也都开着。

    第二次补充: 发现并不是连接不上,而是需要不断的断开连接、重新连接,才能连接上

    opened by lonaking 0
  • 加了mux协议了吗?

    加了mux协议了吗?

    https://github.com/xtaci/smux

    加了heatbeat心跳机制后 , 还需要加mux协议, 这样才能彻底解决 , 感知tcp健康状态,的问题 ,保持长时间连接建议使用“多路复用” 建议看下这2个开源软件: https://github.com/fatedier/frp https://github.com/snail007/goproxy

    opened by hijk1234 0
  • 运行大概6小时之后,tpc隧道会无法连接,http隧道正常

    运行大概6小时之后,tpc隧道会无法连接,http隧道正常

    前天晚上开始使用,发现一觉睡醒就再也连不上tcp隧道了 昨晚又测试了一次,在睡觉前测试时可以连接,睡醒之后就无法连接了,重启客户端恢复正常,我睡觉时间大概5小时,加上睡前的重启行为,推测大概在6小时最后tcp的隧道就会挂掉

    还有以下的问题: 服务端重启了服务,tpc隧道会不可用(http正常)

    客户端环境:ubuntu 16.04位 php:7.1.6

    服务端环境:ubuntu-14.04 64位 php:7.1.3

    bug 
    opened by shuimugan 6
Owner
Tao
基于搜索引擎的复制粘贴工程师 PHPer & Gopher
Tao
ReactPHP HttpClient Adapter for Guzzle6, for Guzzle5 check ReactGuzzleRing

react-guzzle-psr7 ReactPHP HttpClient Adapter for Guzzle6, for Guzzle5 check ReactGuzzleRing Installation To install via Composer, use the command bel

Cees-Jan Kiewiet 69 Dec 8, 2022
A PHP proxy to solve client browser HTTP CORS(cross-origin) restrictions.

cors-bypass-proxy A PHP proxy to solve client browser HTTP CORS(cross-origin) restrictions. A simple way to solve CORS issue when you have no access t

Gracious Emmanuel 15 Nov 17, 2022
Proxy method and property interactions in PHP. ⚡️

Proxy method and property interactions in PHP. Provides a Proxy class that can be used to intercept method calls, property access and updates. Support

Ryan Chandler 4 Mar 28, 2022
A simple script i made that generate a valid http(s) proxy in json format with its geo-location info

Gev Proxy Generator GPG is a simple PHP script that generate a proxy using free services on the web, the proxy is HTTP(s) and it generate it in json f

gev 1 Nov 15, 2021
LittleProxy is a high performance HTTP proxy written in Java atop Trustin Lee's excellent Netty event-based networking library

LittleProxy is a high performance HTTP proxy written in Java atop Trustin Lee's excellent Netty event-based networking library

null 1.9k Dec 26, 2022
Plug & Play [CURL + Composer Optional], Proxy as a Service, Multi-tenant, Multi-Threaded, with Cache & Article Spinner

?? .yxorP The SAAS(y), Multitenancy & Augmenting Web Proxy Guzzler is a 100% SAAS(y) plug-and-play (PHP CURL+Composer are Optional) solution that leverages SAAS architecture to provide multi-tenancy, multiple threads, caching, and an article spinner service.

4D/ҵ.com Dashboards 12 Nov 17, 2022
A modern PHP library that allows you to make resilient calls to external services

Resiliency, an implementation for resilient and modern PHP applications Main principles This library is compatible with PHP 7.4+. Installation compose

We love open source softwares 77 Dec 12, 2022
Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests.

This is a port of the VCR Ruby library to PHP. Record your test suite's HTTP interactions and replay them during future test runs for fast, determinis

php-vcr 1.1k Dec 23, 2022
Creating an all in one AI with a web UI to control it. Create your own AI server and/or sell API keys to other people to use your AI.

+ Currently taking an hour or two break to spend some time with the wife. - Then going to work on auto refreshing the chat and document ingestion so y

null 10 Jun 14, 2023
Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.

Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar

null 3.5k Dec 31, 2022
Supercharge your app or SDK with a testing library specifically for Guzzle

Full Documentation at guzzler.dev Supercharge your app or SDK with a testing library specifically for Guzzle. Guzzler covers the process of setting up

null 275 Oct 30, 2022
Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.

Requests for PHP Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python librar

null 3.5k Dec 31, 2022
Transform your WordPress site into a modern GraphQL server: graphql-api.com.

GraphQL API for WordPress Transform your WordPress site into a modern GraphQL server: graphql-api.com. This plugin is the implementation for WordPress

GraphQL API 151 Dec 14, 2022
This package provides the database factory experience to fake Http calls in your testsuite.

This package provides the database factory experience to fake Http calls in your testsuite

DIJ 11 May 2, 2022
Opsie Operator is a CLI to check your website for HTTP downtime.

Opsie Operator Monitor any website. Run in Docker or any Kubernetes cluster. Send webhooks. ?? Supporting If you are using one or more Renoki Co. open

opsie 14 Dec 6, 2021
Just HTTP Status Codes is a great way to empower your project with clean practice 💫

The Simplest & Cleanest HTTP Status Codes for PHP. All PHP HTTP Status Codes are stored into beautiful constant names ?? Ideal when you develop an API that involves various HTTP codes ??

♚ PH⑦ de Soria™♛ 10 Dec 18, 2022
Satis Control Panel (SCP) is a simple web UI for managing your Satis Repository for Composer Packages.

Satis Control Panel Satis Control Panel (SCP) is a simple web UI for managing your Satis Repository for Composer Packages. SCP backend is written in L

Lukáš Homza 152 Nov 18, 2022
Async HTTP proxy connector, tunnel any TCP/IP-based protocol through an HTTP CONNECT proxy server, built on top of ReactPHP.

clue/reactphp-http-proxy Async HTTP proxy connector, tunnel any TCP/IP-based protocol through an HTTP CONNECT proxy server, built on top of ReactPHP.

Christian Lück 43 Dec 25, 2022
PHP Reverse Shell > reverse-shell.php

PHP Reverse Shell > reverse-shell.php PHP Cmd Shell > cmd.php JPG cmd Shell > cmd.jpg /etc/passwd Pulling Shell > etc-passwd.php Configuration Pulling

Dark-Network 5 Feb 24, 2022
Reverse proxy skeleton built for docker with traefik, showcasing a Symfony + React application

Decoupled Backend(Symfony) + Frontend(React ts) built with Traefik & Docker Reverse proxy skeleton built for docker with traefik, showcasing a decoupl

Sergiu 1 Dec 13, 2021