|
| 1 | +# ProxyHub |
| 2 | + |
| 3 | +[](https://opensource.org/licenses/MIT) |
| 4 | +[](https://nodejs.org/) |
| 5 | +[](https://www.npmjs.com/package/@proxyhub/client) |
| 6 | + |
| 7 | +Expose localhost to the internet. Self-hostable ngrok alternative. |
| 8 | + |
| 9 | +## Quick Start |
| 10 | + |
| 11 | +```bash |
| 12 | +npx @proxyhub/client -p 3000 |
| 13 | +``` |
| 14 | + |
| 15 | +That's it! Your local server running on port 3000 is now accessible from the internet. |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- **Instant Setup** - No account required, just run one command |
| 20 | +- **Token Protection** - Secure your tunnels with authentication tokens |
| 21 | +- **Self-Hostable** - Run your own ProxyHub server |
| 22 | +- **Session Timeouts** - Configurable session duration limits |
| 23 | +- **WebSocket Support** - Full duplex communication via Socket.IO |
| 24 | + |
| 25 | +## Installation |
| 26 | + |
| 27 | +### Using npx (no install) |
| 28 | + |
| 29 | +```bash |
| 30 | +npx @proxyhub/client -p <port> |
| 31 | +``` |
| 32 | + |
| 33 | +### Global install |
| 34 | + |
| 35 | +```bash |
| 36 | +npm install -g @proxyhub/client |
| 37 | +proxyhub -p <port> |
| 38 | +``` |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +### Basic Usage |
| 43 | + |
| 44 | +```bash |
| 45 | +# Expose local port 3000 |
| 46 | +proxyhub -p 3000 |
| 47 | + |
| 48 | +# With debug output |
| 49 | +proxyhub -p 3000 --debug |
| 50 | +``` |
| 51 | + |
| 52 | +### Token Protection |
| 53 | + |
| 54 | +Secure your tunnel so only requests with the correct token can access it: |
| 55 | + |
| 56 | +```bash |
| 57 | +# Using CLI flag |
| 58 | +proxyhub -p 3000 --token mysecrettoken |
| 59 | + |
| 60 | +# Using environment variable |
| 61 | +PROXYHUB_TOKEN=mysecrettoken proxyhub -p 3000 |
| 62 | +``` |
| 63 | + |
| 64 | +When token protection is enabled, requests must include the `X-Proxy-Token` header: |
| 65 | + |
| 66 | +```bash |
| 67 | +curl -H "X-Proxy-Token: mysecrettoken" https://your-tunnel.proxyhub.cloud/ |
| 68 | +``` |
| 69 | + |
| 70 | +### CLI Options |
| 71 | + |
| 72 | +| Option | Description | |
| 73 | +|--------|-------------| |
| 74 | +| `-p, --port <port>` | Port number to proxy (required) | |
| 75 | +| `-t, --token <token>` | Token for tunnel protection | |
| 76 | +| `-d, --debug` | Enable debug mode | |
| 77 | +| `-V, --version` | Output version number | |
| 78 | +| `-h, --help` | Display help | |
| 79 | + |
| 80 | +## Self-Hosting |
| 81 | + |
| 82 | +### Docker (Recommended) |
| 83 | + |
| 84 | +```bash |
| 85 | +docker run -d \ |
| 86 | + -p 4000:4000 \ |
| 87 | + -e BASE_DOMAIN=your-domain.com \ |
| 88 | + -e PROTOCOL=https \ |
| 89 | + -e CONNECTION_TIMEOUT_MINUTES=30 \ |
| 90 | + ghcr.io/cube-root/proxyhub-server:latest |
| 91 | +``` |
| 92 | + |
| 93 | +### Docker Compose |
| 94 | + |
| 95 | +```yaml |
| 96 | +services: |
| 97 | + server: |
| 98 | + build: |
| 99 | + context: ./packages/server |
| 100 | + dockerfile: Dockerfile |
| 101 | + container_name: proxyhub-server |
| 102 | + restart: unless-stopped |
| 103 | + ports: |
| 104 | + - "4000:4000" |
| 105 | + environment: |
| 106 | + - PORT=4000 |
| 107 | + - BASE_DOMAIN=your-domain.com |
| 108 | + - PROTOCOL=https |
| 109 | + - SOCKET_PATH=/socket.io |
| 110 | + - CONNECTION_TIMEOUT_MINUTES=30 |
| 111 | +``` |
| 112 | +
|
| 113 | +### Connect Client to Self-Hosted Server |
| 114 | +
|
| 115 | +```bash |
| 116 | +SOCKET_URL=https://your-server.com proxyhub -p 3000 |
| 117 | +``` |
| 118 | + |
| 119 | +## One-Click Deploy |
| 120 | + |
| 121 | +Deploy your own ProxyHub server with one click: |
| 122 | + |
| 123 | +[](https://cloud.digitalocean.com/apps/new?repo=https://github.com/cube-root/proxyhub/tree/main) |
| 124 | + |
| 125 | +[](https://railway.app/template/proxyhub) |
| 126 | + |
| 127 | +[](https://render.com/deploy?repo=https://github.com/cube-root/proxyhub) |
| 128 | + |
| 129 | +## Environment Variables |
| 130 | + |
| 131 | +### Server |
| 132 | + |
| 133 | +| Variable | Default | Description | |
| 134 | +|----------|---------|-------------| |
| 135 | +| `PORT` | `4000` | Server port | |
| 136 | +| `BASE_DOMAIN` | `proxyhub.cloud` | Base domain for tunnel URLs | |
| 137 | +| `PROTOCOL` | `https` | Protocol for generated URLs | |
| 138 | +| `SOCKET_PATH` | `/socket.io` | Socket.IO path | |
| 139 | +| `CONNECTION_TIMEOUT_MINUTES` | `30` | Session timeout (0 = unlimited) | |
| 140 | + |
| 141 | +### Client |
| 142 | + |
| 143 | +| Variable | Default | Description | |
| 144 | +|----------|---------|-------------| |
| 145 | +| `SOCKET_URL` | `https://connect.proxyhub.cloud` | ProxyHub server URL | |
| 146 | +| `PROXYHUB_TOKEN` | - | Token for tunnel protection | |
| 147 | + |
| 148 | +## How It Works |
| 149 | + |
| 150 | +1. Client connects to ProxyHub server via WebSocket |
| 151 | +2. Server generates a unique tunnel URL (e.g., `https://abc123.proxyhub.cloud`) |
| 152 | +3. Incoming HTTP requests to the tunnel URL are forwarded to the client |
| 153 | +4. Client proxies requests to your local server and streams responses back |
| 154 | + |
| 155 | +``` |
| 156 | +Internet Request Your Local Server |
| 157 | + | ^ |
| 158 | + v | |
| 159 | + ProxyHub Server <--WebSocket--> ProxyHub Client |
| 160 | + (proxyhub.cloud) (your machine) |
| 161 | +``` |
| 162 | + |
| 163 | +## Development |
| 164 | + |
| 165 | +```bash |
| 166 | +# Clone the repository |
| 167 | +git clone https://github.com/cube-root/proxyhub.git |
| 168 | +cd proxyhub |
| 169 | + |
| 170 | +# Install dependencies |
| 171 | +npm install |
| 172 | + |
| 173 | +# Build all packages |
| 174 | +npm run build |
| 175 | + |
| 176 | +# Run server locally |
| 177 | +cd packages/server && npm run dev |
| 178 | + |
| 179 | +# Run client (in another terminal) |
| 180 | +cd packages/client && npm run dev -- -p 3000 |
| 181 | +``` |
| 182 | + |
| 183 | +## License |
| 184 | + |
| 185 | +[MIT](LICENSE) - Copyright (c) 2024 Abhijith V |
0 commit comments