Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
# ProxyHub Configuration

# Server Configuration
CONNECTION_TIMEOUT_MINUTES=30 # Server-side connection timeout in minutes (0 to disable)
SOCKET_URL=https://connect.proxyhub.cloud
SOCKET_PATH=/socket.io
# Server port
PORT=4000

# Base domain for tunnel URLs
# Tunnel URLs will be: https://{tunnel-id}.{BASE_DOMAIN}
# Example: https://a1b2c3d4e5f6.proxyhub.cloud
BASE_DOMAIN=proxyhub.cloud

# Protocol for generated URLs
PROTOCOL=https

# Socket.io path
SOCKET_PATH=/socket.io

# Server-side connection timeout in minutes (0 to disable)
CONNECTION_TIMEOUT_MINUTES=30

# Client configuration
SOCKET_URL=https://connect.proxyhub.cloud

# Pricing Plan Examples:
# Free tier: CONNECTION_TIMEOUT_MINUTES=5 # 5 minute sessions
# Basic tier: CONNECTION_TIMEOUT_MINUTES=30 # 30 minute sessions
# Basic tier: CONNECTION_TIMEOUT_MINUTES=30 # 30 minute sessions
# Pro tier: CONNECTION_TIMEOUT_MINUTES=120 # 2 hour sessions
# Premium tier: CONNECTION_TIMEOUT_MINUTES=0 # Unlimited sessions
# Premium tier: CONNECTION_TIMEOUT_MINUTES=0 # Unlimited sessions
53 changes: 53 additions & 0 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Release Server Docker Image

on:
push:
tags:
- 'server-v*'

permissions:
contents: read
packages: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#server-v}" >> "$GITHUB_OUTPUT"

- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/server
tags: |
type=semver,pattern={{version}},value=${{ steps.version.outputs.VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.version.outputs.VERSION }}
type=semver,pattern={{major}},value=${{ steps.version.outputs.VERSION }}
type=raw,value=latest

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/server
file: ./packages/server/dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Abhijith V

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
68 changes: 68 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ProxyHub Development Makefile

.PHONY: mock-api client server install dev clean help
.PHONY: docker-build docker-up docker-down docker-logs docker-restart

# Default target
help:
@echo "ProxyHub Development Commands"
@echo ""
@echo "Local Development:"
@echo " make mock-api - Start mock API server on port 3000"
@echo " make client - Start ProxyHub client (connects to port 3000)"
@echo " make client-debug - Start client with debug mode"
@echo " make server - Start ProxyHub server"
@echo " make install - Install dependencies for all packages"
@echo " make clean - Clean node_modules"
@echo ""
@echo "Docker:"
@echo " make docker-build - Build Docker image"
@echo " make docker-up - Start server with Docker Compose"
@echo " make docker-down - Stop Docker containers"
@echo " make docker-logs - View Docker logs"
@echo " make docker-restart - Rebuild and restart containers"
@echo ""

# Start mock API server using always-true
mock-api:
npx always-true

# Start ProxyHub client pointing to mock API on port 3000
client:
cd packages/client && npm run dev -- -p 3000

# Start ProxyHub client with debug mode
client-debug:
cd packages/client && npm run dev -- -p 3000 -d

# Start ProxyHub server
server:
cd packages/server && npm run dev

# Install dependencies
install:
npm install
cd packages/client && npm install
cd packages/server && npm install

# Clean node_modules
clean:
rm -rf node_modules
rm -rf packages/client/node_modules
rm -rf packages/server/node_modules

# Docker commands
docker-build:
docker compose build

docker-up:
docker compose up -d

docker-down:
docker compose down

docker-logs:
docker compose logs -f

docker-restart:
docker compose up -d --build
185 changes: 185 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# ProxyHub

[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
[![npm](https://img.shields.io/npm/v/@proxyhub/client)](https://www.npmjs.com/package/@proxyhub/client)

Expose localhost to the internet. Self-hostable ngrok alternative.

## Quick Start

```bash
npx @proxyhub/client -p 3000
```

That's it! Your local server running on port 3000 is now accessible from the internet.

## Features

- **Instant Setup** - No account required, just run one command
- **Token Protection** - Secure your tunnels with authentication tokens
- **Self-Hostable** - Run your own ProxyHub server
- **Session Timeouts** - Configurable session duration limits
- **WebSocket Support** - Full duplex communication via Socket.IO

## Installation

### Using npx (no install)

```bash
npx @proxyhub/client -p <port>
```

### Global install

```bash
npm install -g @proxyhub/client
proxyhub -p <port>
```

## Usage

### Basic Usage

```bash
# Expose local port 3000
proxyhub -p 3000

# With debug output
proxyhub -p 3000 --debug
```

### Token Protection

Secure your tunnel so only requests with the correct token can access it:

```bash
# Using CLI flag
proxyhub -p 3000 --token mysecrettoken

# Using environment variable
PROXYHUB_TOKEN=mysecrettoken proxyhub -p 3000
```

When token protection is enabled, requests must include the `X-Proxy-Token` header:

```bash
curl -H "X-Proxy-Token: mysecrettoken" https://your-tunnel.proxyhub.cloud/
```

### CLI Options

| Option | Description |
|--------|-------------|
| `-p, --port <port>` | Port number to proxy (required) |
| `-t, --token <token>` | Token for tunnel protection |
| `-d, --debug` | Enable debug mode |
| `-V, --version` | Output version number |
| `-h, --help` | Display help |

## Self-Hosting

### Docker (Recommended)

```bash
docker run -d \
-p 4000:4000 \
-e BASE_DOMAIN=your-domain.com \
-e PROTOCOL=https \
-e CONNECTION_TIMEOUT_MINUTES=30 \
ghcr.io/cube-root/proxyhub-server:latest
```

### Docker Compose

```yaml
services:
server:
build:
context: ./packages/server
dockerfile: Dockerfile
container_name: proxyhub-server
restart: unless-stopped
ports:
- "4000:4000"
environment:
- PORT=4000
- BASE_DOMAIN=your-domain.com
- PROTOCOL=https
- SOCKET_PATH=/socket.io
- CONNECTION_TIMEOUT_MINUTES=30
```

### Connect Client to Self-Hosted Server

```bash
SOCKET_URL=https://your-server.com proxyhub -p 3000
```

## One-Click Deploy

Deploy your own ProxyHub server with one click:

[![Deploy to DO](https://www.deploytodo.com/do-btn-blue.svg)](https://cloud.digitalocean.com/apps/new?repo=https://github.com/cube-root/proxyhub/tree/main)

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/proxyhub)

[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/cube-root/proxyhub)

## Environment Variables

### Server

| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `4000` | Server port |
| `BASE_DOMAIN` | `proxyhub.cloud` | Base domain for tunnel URLs |
| `PROTOCOL` | `https` | Protocol for generated URLs |
| `SOCKET_PATH` | `/socket.io` | Socket.IO path |
| `CONNECTION_TIMEOUT_MINUTES` | `30` | Session timeout (0 = unlimited) |

### Client

| Variable | Default | Description |
|----------|---------|-------------|
| `SOCKET_URL` | `https://connect.proxyhub.cloud` | ProxyHub server URL |
| `PROXYHUB_TOKEN` | - | Token for tunnel protection |

## How It Works

1. Client connects to ProxyHub server via WebSocket
2. Server generates a unique tunnel URL (e.g., `https://abc123.proxyhub.cloud`)
3. Incoming HTTP requests to the tunnel URL are forwarded to the client
4. Client proxies requests to your local server and streams responses back

```
Internet Request Your Local Server
| ^
v |
ProxyHub Server <--WebSocket--> ProxyHub Client
(proxyhub.cloud) (your machine)
```

## Development

```bash
# Clone the repository
git clone https://github.com/cube-root/proxyhub.git
cd proxyhub

# Install dependencies
npm install

# Build all packages
npm run build

# Run server locally
cd packages/server && npm run dev

# Run client (in another terminal)
cd packages/client && npm run dev -- -p 3000
```

## License

[MIT](LICENSE) - Copyright (c) 2024 Abhijith V
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
server:
build:
context: ./packages/server
dockerfile: Dockerfile
container_name: proxyhub-server
restart: unless-stopped
ports:
- "4000:4000"
environment:
- PORT=4000
- BASE_DOMAIN=${BASE_DOMAIN:-proxyhub.cloud}
- PROTOCOL=${PROTOCOL:-https}
- SOCKET_PATH=${SOCKET_PATH:-/socket.io}
- CONNECTION_TIMEOUT_MINUTES=${CONNECTION_TIMEOUT_MINUTES:-30}
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:4000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
Loading
Loading