opentunnel-cli 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -877
- package/dist/cli/index.js +55 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/server/TunnelServer.d.ts +6 -0
- package/dist/server/TunnelServer.d.ts.map +1 -1
- package/dist/server/TunnelServer.js +164 -0
- package/dist/server/TunnelServer.js.map +1 -1
- package/dist/shared/types.d.ts +12 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -4,943 +4,111 @@
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
## Table of Contents
|
|
8
|
-
|
|
9
|
-
- [As a Client](#-as-a-client) - Expose your local ports
|
|
10
|
-
- [As a Server](#-as-a-server) - Host your own tunnel server
|
|
11
|
-
- [Home Use](#-home-use-behind-routernat) - Run from home network
|
|
12
|
-
- [Multi-Domain Support](#-multi-domain-support) - Handle multiple domains on one server
|
|
13
|
-
- [Authentication](#-authentication) - Secure your server
|
|
14
|
-
- [IP Access Control](#-ip-access-control) - Allow/deny IPs and CIDR ranges
|
|
15
|
-
- [Configuration File](#-configuration-file) - opentunnel.yml reference
|
|
16
|
-
- [Environment Variables](#environment-variables) - Docker-style ${VAR:-default} syntax
|
|
17
|
-
- [Commands Reference](#-commands-reference)
|
|
18
|
-
- [Expose Local (expl)](#expose-local-command-expl) - Fastest way to expose a port
|
|
19
|
-
- [Domain Configuration](#domain-configuration) - Set default domain
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
# 📱 As a Client
|
|
24
|
-
|
|
25
|
-
Use OpenTunnel to expose your local services to the internet. Connect to any OpenTunnel server (your own or one shared with you).
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# NPM (recommended)
|
|
31
|
-
npm cache clean --force && npm install -g opentunnel-cli
|
|
32
|
-
|
|
33
|
-
# Or use without installing
|
|
34
|
-
npx opentunnel-cli quick 3000 -s example.com
|
|
35
|
-
```
|
|
36
|
-
|
|
37
7
|
## Quick Start
|
|
38
8
|
|
|
39
|
-
###
|
|
40
|
-
|
|
41
|
-
The fastest way to expose a port with your own domain:
|
|
9
|
+
### Installation
|
|
42
10
|
|
|
43
11
|
```bash
|
|
44
|
-
|
|
45
|
-
opentunnel setdomain yourdomain.com
|
|
46
|
-
|
|
47
|
-
# Then expose any port with a single command
|
|
48
|
-
opentunnel expl 3000
|
|
12
|
+
npm install -g opentunnel-cli
|
|
49
13
|
```
|
|
50
14
|
|
|
51
|
-
|
|
52
|
-
[Check this](#-home-use-behind-routernat) - Run from home network
|
|
53
|
-
|
|
54
|
-
### Option 2: Quick Command
|
|
15
|
+
### As a Client
|
|
55
16
|
|
|
56
17
|
Connect to an existing OpenTunnel server:
|
|
57
18
|
|
|
58
19
|
```bash
|
|
59
|
-
#
|
|
20
|
+
# Quick tunnel
|
|
60
21
|
opentunnel quick 3000 -s example.com
|
|
61
22
|
|
|
62
|
-
# Or start your own local server
|
|
63
|
-
opentunnel quick 3000 -s yourdomain.com --local-server
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Your local port 3000 is now accessible from the internet:
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
Status: ● Online
|
|
70
|
-
Local: localhost:3000
|
|
71
|
-
Public: https://myapp.op.example.com
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Options:**
|
|
75
|
-
```bash
|
|
76
|
-
opentunnel quick 3000 -s example.com # Basic HTTP tunnel
|
|
77
|
-
opentunnel quick 3000 --domain example.com -n myapp # Custom subdomain
|
|
78
|
-
opentunnel quick 5432 -s example.com -p tcp # TCP tunnel
|
|
79
|
-
opentunnel quick 3000 -s example.com -t SECRET # With auth token
|
|
80
|
-
opentunnel quick 3000 -s example.com --insecure # Self-signed cert
|
|
81
|
-
opentunnel quick 3000 -s example.com -b "" # No basePath (direct domain)
|
|
82
|
-
opentunnel quick 3000 -s yourdomain.com --local-server # Start server + tunnel in one terminal
|
|
83
|
-
#
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Option 3: HTTP/TCP Commands
|
|
87
|
-
|
|
88
|
-
More control with specific commands:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# HTTP tunnel
|
|
92
|
-
opentunnel http 3000 -s example.com
|
|
93
|
-
opentunnel http 3000 --domain example.com --subdomain myapp
|
|
94
|
-
|
|
95
23
|
# With authentication
|
|
96
|
-
opentunnel
|
|
97
|
-
|
|
98
|
-
# TCP tunnel
|
|
99
|
-
opentunnel tcp 5432 -s example.com -r 15432
|
|
100
|
-
opentunnel tcp 5432 --domain example.com --remote-port 15432
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Option 4: Using Config File
|
|
104
|
-
|
|
105
|
-
Create `opentunnel.yml`:
|
|
106
|
-
|
|
107
|
-
```yaml
|
|
108
|
-
server:
|
|
109
|
-
remote: example.com # Base domain (system adds basePath)
|
|
110
|
-
token: ${AUTH_TOKEN} # From .env file (optional)
|
|
111
|
-
|
|
112
|
-
tunnels:
|
|
113
|
-
- name: web
|
|
114
|
-
protocol: http
|
|
115
|
-
port: 3000
|
|
116
|
-
subdomain: myapp # → myapp.op.example.com
|
|
117
|
-
|
|
118
|
-
- name: api
|
|
119
|
-
protocol: http
|
|
120
|
-
port: 4000
|
|
121
|
-
subdomain: api # → api.op.example.com
|
|
122
|
-
|
|
123
|
-
- name: postgres
|
|
124
|
-
protocol: tcp
|
|
125
|
-
port: 5432
|
|
126
|
-
remotePort: 15432 # → example.com:15432
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
opentunnel up # Start all tunnels
|
|
131
|
-
opentunnel up -d # Start in background
|
|
132
|
-
opentunnel down # Stop all tunnels
|
|
133
|
-
opentunnel ps # Check status
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
# 🖥️ As a Server
|
|
139
|
-
|
|
140
|
-
Host your own OpenTunnel server to have full control. Your server can be **public** (anyone can connect) or **private** (requires authentication).
|
|
141
|
-
|
|
142
|
-
## Requirements
|
|
143
|
-
|
|
144
|
-
- **VPS or server** with a public IP address
|
|
145
|
-
- **Domain** pointing to your server
|
|
146
|
-
- **Ports** 443 (HTTPS) and optionally 10000-20000 (TCP tunnels)
|
|
147
|
-
|
|
148
|
-
## DNS Configuration
|
|
149
|
-
|
|
150
|
-
Create these DNS records pointing to your server:
|
|
151
|
-
|
|
152
|
-
| Type | Name | Value | Notes |
|
|
153
|
-
|------|------|-------|-------|
|
|
154
|
-
| A | `op` | `YOUR_SERVER_IP` | Main server (or your basePath) |
|
|
155
|
-
| A | `*.op` | `YOUR_SERVER_IP` | Wildcard for subdomains |
|
|
156
|
-
|
|
157
|
-
> **Cloudflare users:** Set proxy status to "DNS only" (gray cloud)
|
|
158
|
-
|
|
159
|
-
Example for domain `example.com`:
|
|
160
|
-
- `op.example.com` → Your server IP
|
|
161
|
-
- `*.op.example.com` → Your server IP (wildcard)
|
|
162
|
-
|
|
163
|
-
Tunnels will be available at: `https://myapp.op.example.com`
|
|
164
|
-
|
|
165
|
-
## Deployment Options
|
|
166
|
-
|
|
167
|
-
### Option 1: Quick Start (Manual)
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
# Install
|
|
171
|
-
npm cache clean --force && npm install -g opentunnel-cli
|
|
172
|
-
|
|
173
|
-
# Start public server (anyone can connect)
|
|
174
|
-
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
|
|
175
|
-
|
|
176
|
-
# Start private server (requires token to connect)
|
|
177
|
-
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "SECRET123"
|
|
178
|
-
|
|
179
|
-
# Stop server
|
|
180
|
-
opentunnel stop
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Option 2: Using Config File
|
|
184
|
-
|
|
185
|
-
Create `opentunnel.yml`:
|
|
186
|
-
|
|
187
|
-
```yaml
|
|
188
|
-
server:
|
|
189
|
-
domain: example.com # Base domain only
|
|
190
|
-
# token: SECRET123 # Uncomment for private server
|
|
191
|
-
# tcpPortMin: 10000 # TCP tunnel port range (optional)
|
|
192
|
-
# tcpPortMax: 20000
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
opentunnel server -d # Start in background (reads from opentunnel.yml)
|
|
197
|
-
opentunnel stop # Stop server
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Option 3: Docker (Recommended for Production)
|
|
201
|
-
|
|
202
|
-
```bash
|
|
203
|
-
git clone https://github.com/FJRG2007/opentunnel.git
|
|
204
|
-
cd opentunnel
|
|
205
|
-
|
|
206
|
-
# Configure
|
|
207
|
-
cp .env.example .env
|
|
208
|
-
nano .env
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Edit `.env`:
|
|
212
|
-
```env
|
|
213
|
-
DOMAIN=example.com # Base domain only (without the op prefix)
|
|
214
|
-
AUTH_TOKENS=SECRET123 # Leave empty for public server
|
|
215
|
-
LETSENCRYPT_EMAIL=admin@example.com
|
|
216
|
-
LETSENCRYPT_PRODUCTION=true
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
docker-compose up -d
|
|
221
|
-
docker-compose down # Stop server
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Option 4: One-Line Install (Linux with systemd)
|
|
24
|
+
opentunnel quick 3000 -s example.com -t YOUR_TOKEN
|
|
225
25
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Then configure:
|
|
231
|
-
```bash
|
|
232
|
-
sudo nano /opt/opentunnel/.env
|
|
233
|
-
sudo systemctl start opentunnel
|
|
234
|
-
sudo systemctl stop opentunnel
|
|
235
|
-
sudo systemctl status opentunnel
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
## Server Options
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
opentunnel server [options]
|
|
242
|
-
|
|
243
|
-
Required:
|
|
244
|
-
--domain <domain> Your base domain (e.g., example.com)
|
|
245
|
-
Tunnels will be at: *.op.example.com
|
|
246
|
-
|
|
247
|
-
Optional:
|
|
248
|
-
-p, --port <port> Server port (default: 443)
|
|
249
|
-
-b, --base-path <path> Subdomain prefix (default: op, empty for direct)
|
|
250
|
-
--tcp-min <port> Min TCP tunnel port (default: 10000)
|
|
251
|
-
--tcp-max <port> Max TCP tunnel port (default: 20000)
|
|
252
|
-
-d, --detach Run in background
|
|
253
|
-
|
|
254
|
-
Authentication:
|
|
255
|
-
--auth-tokens <tokens> Comma-separated tokens for private server
|
|
256
|
-
Leave empty for public server
|
|
257
|
-
|
|
258
|
-
SSL/TLS:
|
|
259
|
-
--letsencrypt Enable Let's Encrypt certificates
|
|
260
|
-
--email <email> Email for Let's Encrypt
|
|
261
|
-
--production Use Let's Encrypt production (not staging)
|
|
262
|
-
--cloudflare-token <token> Cloudflare API token for DNS-01 challenge
|
|
263
|
-
|
|
264
|
-
IP Access Control:
|
|
265
|
-
--ip-mode <mode> Access mode: all, allowlist, denylist (default: all)
|
|
266
|
-
--ip-allow <ips> Comma-separated IPs/CIDRs to allow
|
|
267
|
-
--ip-deny <ips> Comma-separated IPs/CIDRs to deny
|
|
26
|
+
# Custom subdomain
|
|
27
|
+
opentunnel quick 3000 -s example.com -n myapp
|
|
28
|
+
# → https://myapp.op.example.com
|
|
268
29
|
```
|
|
269
30
|
|
|
270
|
-
|
|
31
|
+
### As a Server
|
|
271
32
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
Anyone can connect without authentication:
|
|
33
|
+
Host your own tunnel server:
|
|
275
34
|
|
|
276
35
|
```bash
|
|
36
|
+
# Public server
|
|
277
37
|
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
Clients connect with:
|
|
281
|
-
```bash
|
|
282
|
-
opentunnel quick 3000 -s example.com
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
### Private Server
|
|
286
|
-
|
|
287
|
-
Only clients with valid tokens can connect:
|
|
288
|
-
|
|
289
|
-
```bash
|
|
290
|
-
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "token1,token2"
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
Clients must provide a token:
|
|
294
|
-
```bash
|
|
295
|
-
opentunnel quick 3000 -s example.com -t token1
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
---
|
|
299
|
-
|
|
300
|
-
# 🏠 Home Use (Behind Router/NAT)
|
|
301
|
-
|
|
302
|
-
If you want to run OpenTunnel server from your home network, you need to configure your router properly.
|
|
303
|
-
|
|
304
|
-
## Step 1: Static Internal IP
|
|
305
|
-
|
|
306
|
-
First, assign a static IP to your computer in your router's DHCP settings. This prevents your IP from changing after a reboot.
|
|
307
|
-
|
|
308
|
-
**Example:** `192.168.1.134`
|
|
309
|
-
|
|
310
|
-
Most routers have this in: **Settings → LAN → DHCP Reservation** or **Address Reservation**
|
|
311
|
-
|
|
312
|
-
## Step 2: Port Forwarding
|
|
313
|
-
|
|
314
|
-
Configure your router to forward external ports to your computer:
|
|
315
|
-
|
|
316
|
-
| Name | Protocol | WAN Port | LAN Host | LAN Port | Description |
|
|
317
|
-
|------|----------|----------|----------|----------|-------------|
|
|
318
|
-
| OpenTunnel HTTP | TCP/UDP | 80 | 192.168.1.134 | 8080 | Let's Encrypt HTTP-01 challenge |
|
|
319
|
-
| OpenTunnel HTTPS | TCP | 443 | 192.168.1.134 | 443 | Main HTTPS traffic |
|
|
320
|
-
| OpenTunnel TCP | TCP/UDP | 10000-20000 | 192.168.1.134 | 10000-20000 | TCP tunnel ports |
|
|
321
|
-
|
|
322
|
-
> **Note:** Replace `192.168.1.134` with your computer's static IP.
|
|
323
|
-
|
|
324
|
-
## Step 3: Dynamic DNS (Optional)
|
|
325
38
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
- **DuckDNS** (free): `yourdomain.duckdns.org`
|
|
329
|
-
- **Cloudflare** (free tier): Use with your own domain
|
|
330
|
-
- **No-IP**, **DynDNS**, etc.
|
|
331
|
-
|
|
332
|
-
## Step 4: Start the Server
|
|
333
|
-
|
|
334
|
-
```bash
|
|
335
|
-
# With Let's Encrypt (recommended)
|
|
336
|
-
opentunnel server -d --domain yourdomain.duckdns.org --letsencrypt --email you@email.com --production
|
|
337
|
-
|
|
338
|
-
# With self-signed certificate (for testing)
|
|
339
|
-
opentunnel server -d --domain yourdomain.duckdns.org
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
## Step 5: Connect from Anywhere
|
|
343
|
-
|
|
344
|
-
From any other network:
|
|
345
|
-
|
|
346
|
-
```bash
|
|
347
|
-
opentunnel quick 3000 -s yourdomain.duckdns.org
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
## Quick Hybrid Mode (Server + Tunnel in One)
|
|
351
|
-
|
|
352
|
-
For the simplest setup, expose a local port while running the server:
|
|
353
|
-
|
|
354
|
-
```bash
|
|
355
|
-
# Easiest: set default domain once, then use expl
|
|
356
|
-
opentunnel setdomain yourdomain.duckdns.org
|
|
357
|
-
opentunnel expl 3000
|
|
358
|
-
|
|
359
|
-
# Or specify domain each time
|
|
360
|
-
opentunnel expl 3000 -s yourdomain.duckdns.org
|
|
361
|
-
|
|
362
|
-
# Alternative with quick command
|
|
363
|
-
opentunnel quick 3000 -s yourdomain.duckdns.org --local-server
|
|
364
|
-
|
|
365
|
-
# Or with config file
|
|
366
|
-
opentunnel init --hybrid
|
|
367
|
-
opentunnel up
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
## Troubleshooting
|
|
371
|
-
|
|
372
|
-
**Ports not accessible from outside:**
|
|
373
|
-
1. Check your ISP doesn't block ports 80/443 (some do for residential)
|
|
374
|
-
2. Verify port forwarding rules are active
|
|
375
|
-
3. Test from a different network (not from inside your home network)
|
|
376
|
-
4. Check Windows Firewall / Linux iptables rules
|
|
377
|
-
|
|
378
|
-
**Use alternative ports if ISP blocks 80/443:**
|
|
379
|
-
```bash
|
|
380
|
-
opentunnel server -d --domain yourdomain.com -p 8443 --public-port 8443
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
---
|
|
384
|
-
|
|
385
|
-
# 🌐 Multi-Domain Support
|
|
386
|
-
|
|
387
|
-
OpenTunnel can handle **multiple domains** on a single server instance. Each domain works independently - clients connect to whichever domain they prefer and create their own tunnels.
|
|
388
|
-
|
|
389
|
-
## DNS Configuration
|
|
390
|
-
|
|
391
|
-
For each domain you want to use, create DNS records pointing to your server:
|
|
392
|
-
|
|
393
|
-
| Domain | Type | Name | Value |
|
|
394
|
-
|--------|------|------|-------|
|
|
395
|
-
| `domain1.com` | A | `op` | `YOUR_SERVER_IP` |
|
|
396
|
-
| `domain1.com` | A | `*.op` | `YOUR_SERVER_IP` |
|
|
397
|
-
| `domain2.com` | A | `op` | `YOUR_SERVER_IP` |
|
|
398
|
-
| `domain2.com` | A | `*.op` | `YOUR_SERVER_IP` |
|
|
399
|
-
|
|
400
|
-
## Server Configuration
|
|
401
|
-
|
|
402
|
-
Configure the server with multiple domains in `opentunnel.yml`:
|
|
403
|
-
|
|
404
|
-
```yaml
|
|
405
|
-
server:
|
|
406
|
-
domains:
|
|
407
|
-
- domain: domain1.com
|
|
408
|
-
basePath: op # Accepts tunnels at: *.op.domain1.com
|
|
409
|
-
- domain: domain2.com
|
|
410
|
-
basePath: op # Accepts tunnels at: *.op.domain2.com
|
|
411
|
-
port: 443
|
|
39
|
+
# Private server (with auth)
|
|
40
|
+
opentunnel server -d --domain example.com --letsencrypt --email admin@example.com --auth-tokens "SECRET"
|
|
412
41
|
```
|
|
413
42
|
|
|
414
|
-
|
|
415
|
-
```bash
|
|
416
|
-
opentunnel up -d
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
## How Clients Connect
|
|
43
|
+
**DNS Setup:** Point `op.example.com` and `*.op.example.com` to your server IP.
|
|
420
44
|
|
|
421
|
-
|
|
45
|
+
### Home Use (Hybrid Mode)
|
|
422
46
|
|
|
423
|
-
|
|
424
|
-
```bash
|
|
425
|
-
opentunnel quick 3000 -s domain1.com -n myapp
|
|
426
|
-
# → https://myapp.op.domain1.com
|
|
427
|
-
```
|
|
47
|
+
Run server + tunnel in one terminal:
|
|
428
48
|
|
|
429
|
-
**Client B** (connects to domain2.com):
|
|
430
49
|
```bash
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
**Client C** (also connects to domain1.com):
|
|
436
|
-
```bash
|
|
437
|
-
opentunnel quick 5000 -s domain1.com -n backend
|
|
438
|
-
# → https://backend.op.domain1.com
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
Each tunnel only exists on the domain the client connected to.
|
|
442
|
-
|
|
443
|
-
## Single Domain (Backward Compatible)
|
|
444
|
-
|
|
445
|
-
If you only need one domain:
|
|
446
|
-
|
|
447
|
-
```yaml
|
|
448
|
-
server:
|
|
449
|
-
domain: example.com
|
|
450
|
-
basePath: op
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
## Domains Without Wildcard Support (DuckDNS)
|
|
454
|
-
|
|
455
|
-
Some DNS providers like **DuckDNS** don't support wildcard subdomains (`*.domain`). OpenTunnel automatically detects DuckDNS domains and uses **port-based routing** instead of subdomains.
|
|
456
|
-
|
|
457
|
-
**Auto-detection:** Domains ending in `.duckdns.org` automatically use port-based mode.
|
|
458
|
-
|
|
459
|
-
**Important:** DuckDNS domains cannot use `basePath` - it will throw an error:
|
|
460
|
-
|
|
461
|
-
```yaml
|
|
462
|
-
# ❌ WRONG - Will throw an error
|
|
463
|
-
server:
|
|
464
|
-
domains:
|
|
465
|
-
- domain: myapp.duckdns.org
|
|
466
|
-
basePath: op # Error! DuckDNS doesn't support subdomains
|
|
467
|
-
|
|
468
|
-
# ✅ CORRECT
|
|
469
|
-
server:
|
|
470
|
-
domains:
|
|
471
|
-
- domain: fjrg2007.com
|
|
472
|
-
basePath: op # Subdomain-based: *.op.fjrg2007.com
|
|
473
|
-
- domain: myapp.duckdns.org
|
|
474
|
-
# Port-based: myapp.duckdns.org:<port>
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
**Manual configuration:** Use `wildcard: false` for other domains without wildcard support:
|
|
478
|
-
|
|
479
|
-
```yaml
|
|
480
|
-
server:
|
|
481
|
-
domains:
|
|
482
|
-
- domain: fjrg2007.com
|
|
483
|
-
basePath: op # Subdomain-based: *.op.fjrg2007.com
|
|
484
|
-
- domain: other-no-wildcard.com
|
|
485
|
-
wildcard: false # Manual: port-based
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
**How it works:**
|
|
489
|
-
- **Wildcard domains:** `https://myapp.op.fjrg2007.com`
|
|
490
|
-
- **Non-wildcard domains:** `https://myapp.duckdns.org:10001`
|
|
491
|
-
|
|
492
|
-
Clients connecting to non-wildcard domains receive port-based URLs automatically.
|
|
493
|
-
|
|
494
|
-
## SSL Certificates
|
|
495
|
-
|
|
496
|
-
When using self-signed certificates with multiple domains, OpenTunnel automatically generates a **SAN (Subject Alternative Name) certificate** that covers all configured domains and their wildcards.
|
|
497
|
-
|
|
498
|
-
For Let's Encrypt, you'll need separate certificates or a multi-domain certificate with all your domains listed.
|
|
499
|
-
|
|
500
|
-
## Use Cases
|
|
501
|
-
|
|
502
|
-
### Different Teams/Projects
|
|
503
|
-
|
|
504
|
-
```yaml
|
|
505
|
-
server:
|
|
506
|
-
domains:
|
|
507
|
-
- domain: dev.company.com
|
|
508
|
-
basePath: op # Dev team connects here
|
|
509
|
-
- domain: staging.company.com
|
|
510
|
-
basePath: op # QA team connects here
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
### White-Label Service
|
|
514
|
-
|
|
515
|
-
```yaml
|
|
516
|
-
server:
|
|
517
|
-
domains:
|
|
518
|
-
- domain: client1.com
|
|
519
|
-
basePath: op # Client 1's tunnels
|
|
520
|
-
- domain: client2.com
|
|
521
|
-
basePath: op # Client 2's tunnels
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
### Migration Between Domains
|
|
525
|
-
|
|
526
|
-
```yaml
|
|
527
|
-
server:
|
|
528
|
-
domains:
|
|
529
|
-
- domain: newdomain.com
|
|
530
|
-
basePath: op # New domain
|
|
531
|
-
- domain: olddomain.com
|
|
532
|
-
basePath: op # Old domain (still supported)
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
---
|
|
536
|
-
|
|
537
|
-
# 🔐 Authentication
|
|
538
|
-
|
|
539
|
-
OpenTunnel uses a **shared secret** system for authentication. The server defines a list of valid tokens, and clients must provide one to connect.
|
|
540
|
-
|
|
541
|
-
## Server Setup
|
|
542
|
-
|
|
543
|
-
```bash
|
|
544
|
-
# Single token
|
|
545
|
-
opentunnel server -d --domain example.com --auth-tokens "my-secret-token"
|
|
546
|
-
|
|
547
|
-
# Multiple tokens (one per user/team)
|
|
548
|
-
opentunnel server -d --domain example.com --auth-tokens "team-a-token,team-b-token,dev-token"
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
Or in `opentunnel.yml`:
|
|
552
|
-
```yaml
|
|
553
|
-
server:
|
|
554
|
-
domain: example.com
|
|
555
|
-
token: my-secret-token
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
Or in `.env`:
|
|
559
|
-
```env
|
|
560
|
-
AUTH_TOKENS=team-a-token,team-b-token,dev-token
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
## Client Usage
|
|
564
|
-
|
|
565
|
-
```bash
|
|
566
|
-
# Command line
|
|
567
|
-
opentunnel quick 3000 -s example.com -t my-secret-token
|
|
568
|
-
|
|
569
|
-
# Or in opentunnel.yml
|
|
570
|
-
server:
|
|
571
|
-
remote: example.com
|
|
572
|
-
token: my-secret-token
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
## Security Recommendations
|
|
576
|
-
|
|
577
|
-
1. **Use strong tokens**: Generate random strings (e.g., `openssl rand -hex 32`)
|
|
578
|
-
2. **One token per user/team**: Easier to revoke access if needed
|
|
579
|
-
3. **HTTPS only**: Always use `--letsencrypt` in production
|
|
580
|
-
4. **Rotate tokens periodically**: Update tokens and notify users
|
|
581
|
-
|
|
582
|
-
---
|
|
583
|
-
|
|
584
|
-
# 🛡️ IP Access Control
|
|
585
|
-
|
|
586
|
-
Control which IP addresses can connect to your server. By default, all IPs are allowed.
|
|
587
|
-
|
|
588
|
-
## Access Modes
|
|
589
|
-
|
|
590
|
-
| Mode | Description |
|
|
591
|
-
|------|-------------|
|
|
592
|
-
| `all` | Allow all IPs (default) |
|
|
593
|
-
| `allowlist` | Only allow IPs in the allow list |
|
|
594
|
-
| `denylist` | Deny IPs in the deny list, allow others |
|
|
595
|
-
|
|
596
|
-
## Command Line
|
|
597
|
-
|
|
598
|
-
```bash
|
|
599
|
-
# Only allow specific IPs/ranges
|
|
600
|
-
opentunnel server -d --domain example.com --ip-mode allowlist --ip-allow "192.168.1.0/24,10.0.0.1"
|
|
601
|
-
|
|
602
|
-
# Deny specific IPs
|
|
603
|
-
opentunnel server -d --domain example.com --ip-mode denylist --ip-deny "1.2.3.4,5.6.7.0/24"
|
|
604
|
-
```
|
|
605
|
-
|
|
606
|
-
## Configuration File
|
|
607
|
-
|
|
608
|
-
```yaml
|
|
609
|
-
server:
|
|
610
|
-
domain: example.com
|
|
611
|
-
token: ${AUTH_TOKEN}
|
|
612
|
-
ipAccess:
|
|
613
|
-
mode: allowlist # all, allowlist, or denylist
|
|
614
|
-
allowList:
|
|
615
|
-
- 192.168.1.0/24 # Allow entire subnet
|
|
616
|
-
- 10.0.0.1 # Allow single IP
|
|
617
|
-
- 172.16.0.0/16 # Allow another range
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
```yaml
|
|
621
|
-
server:
|
|
622
|
-
domain: example.com
|
|
623
|
-
ipAccess:
|
|
624
|
-
mode: denylist
|
|
625
|
-
denyList:
|
|
626
|
-
- 1.2.3.4 # Block single IP
|
|
627
|
-
- 5.6.7.0/24 # Block entire subnet
|
|
628
|
-
```
|
|
629
|
-
|
|
630
|
-
## Supported Formats
|
|
631
|
-
|
|
632
|
-
- Single IP: `192.168.1.1`
|
|
633
|
-
- CIDR notation: `192.168.1.0/24` (256 addresses)
|
|
634
|
-
- IPv6: `::1`, `2001:db8::/32`
|
|
635
|
-
|
|
636
|
-
---
|
|
637
|
-
|
|
638
|
-
# 📄 Configuration File
|
|
639
|
-
|
|
640
|
-
Create `opentunnel.yml` in your project directory.
|
|
641
|
-
|
|
642
|
-
## Environment Variables
|
|
643
|
-
|
|
644
|
-
OpenTunnel supports **Docker-style environment variable substitution** in config files. Variables are loaded from `.env` file automatically.
|
|
645
|
-
|
|
646
|
-
| Syntax | Description |
|
|
647
|
-
|--------|-------------|
|
|
648
|
-
| `${VAR}` | Use value of VAR |
|
|
649
|
-
| `${VAR:-default}` | Use VAR if set, otherwise use "default" |
|
|
650
|
-
| `${VAR:=default}` | Same as above (alternative syntax) |
|
|
651
|
-
|
|
652
|
-
**Example with `.env` file:**
|
|
653
|
-
|
|
654
|
-
```env
|
|
655
|
-
# .env
|
|
656
|
-
AUTH_TOKEN=my-secret-token
|
|
657
|
-
SERVER_DOMAIN=example.com
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
```yaml
|
|
661
|
-
# opentunnel.yml
|
|
662
|
-
server:
|
|
663
|
-
remote: ${SERVER_DOMAIN:-localhost} # Uses example.com from .env
|
|
664
|
-
token: ${AUTH_TOKEN} # Uses my-secret-token from .env
|
|
665
|
-
|
|
666
|
-
tunnels:
|
|
667
|
-
- name: web
|
|
668
|
-
protocol: http
|
|
669
|
-
port: 3000
|
|
670
|
-
subdomain: app
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
## Client Mode (connect to remote server)
|
|
674
|
-
|
|
675
|
-
```yaml
|
|
676
|
-
server:
|
|
677
|
-
remote: ${SERVER_DOMAIN:-example.com} # Base domain (system adds basePath)
|
|
678
|
-
token: ${AUTH_TOKEN} # From .env (optional)
|
|
679
|
-
|
|
680
|
-
tunnels:
|
|
681
|
-
- name: frontend
|
|
682
|
-
protocol: http
|
|
683
|
-
port: 3000
|
|
684
|
-
subdomain: app # → app.op.example.com
|
|
685
|
-
|
|
686
|
-
- name: backend
|
|
687
|
-
protocol: http
|
|
688
|
-
port: 4000
|
|
689
|
-
subdomain: api # → api.op.example.com
|
|
690
|
-
|
|
691
|
-
- name: database
|
|
692
|
-
protocol: tcp
|
|
693
|
-
port: 5432
|
|
694
|
-
remotePort: 15432 # → example.com:15432
|
|
695
|
-
autostart: false # Don't start automatically
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
## Server Mode (run your own server)
|
|
699
|
-
|
|
700
|
-
```yaml
|
|
701
|
-
server:
|
|
702
|
-
domain: ${DOMAIN:-example.com} # Base domain only
|
|
703
|
-
token: ${AUTH_TOKEN} # Optional: for private server
|
|
704
|
-
# tcpPortMin: 10000 # TCP tunnel port range (optional)
|
|
705
|
-
# tcpPortMax: 20000
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
## Hybrid Mode (server + tunnels in one terminal)
|
|
709
|
-
|
|
710
|
-
For home use or development, you can run the server AND expose local ports in the same terminal without needing a separate server process.
|
|
711
|
-
|
|
712
|
-
```yaml
|
|
713
|
-
mode: hybrid # Server + tunnels in one terminal
|
|
714
|
-
|
|
715
|
-
server:
|
|
716
|
-
domain: ${DOMAIN:-example.com} # Your domain
|
|
717
|
-
token: ${AUTH_TOKEN} # Optional
|
|
718
|
-
|
|
719
|
-
tunnels:
|
|
720
|
-
- name: web
|
|
721
|
-
protocol: http
|
|
722
|
-
port: 3000
|
|
723
|
-
subdomain: web # → web.op.example.com
|
|
724
|
-
|
|
725
|
-
- name: api
|
|
726
|
-
protocol: http
|
|
727
|
-
port: 4000
|
|
728
|
-
subdomain: api # → api.op.example.com
|
|
729
|
-
```
|
|
730
|
-
|
|
731
|
-
```bash
|
|
732
|
-
opentunnel up # Starts server + all tunnels
|
|
733
|
-
```
|
|
50
|
+
# Set default domain (one time)
|
|
51
|
+
opentunnel setdomain yourdomain.com
|
|
734
52
|
|
|
735
|
-
|
|
736
|
-
```bash
|
|
737
|
-
# Easiest way (with default domain set)
|
|
53
|
+
# Expose any port
|
|
738
54
|
opentunnel expl 3000
|
|
739
|
-
|
|
740
|
-
# Or with explicit domain
|
|
741
|
-
opentunnel expl 3000 -s yourdomain.com
|
|
742
|
-
|
|
743
|
-
# Alternative
|
|
744
|
-
opentunnel quick 3000 -s yourdomain.com --local-server
|
|
745
|
-
```
|
|
746
|
-
|
|
747
|
-
## Commands
|
|
748
|
-
|
|
749
|
-
```bash
|
|
750
|
-
opentunnel init # Create example config file
|
|
751
|
-
opentunnel up # Start server/tunnels from config
|
|
752
|
-
opentunnel up -d # Start in background
|
|
753
|
-
opentunnel down # Stop everything
|
|
754
|
-
opentunnel stop # Stop server
|
|
755
|
-
opentunnel ps # Show running processes
|
|
756
55
|
```
|
|
757
56
|
|
|
758
57
|
---
|
|
759
58
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
|
763
|
-
|
|
764
|
-
|
|
|
765
|
-
|
|
|
766
|
-
|
|
|
767
|
-
|
|
|
768
|
-
|
|
|
769
|
-
|
|
|
770
|
-
|
|
|
771
|
-
|
|
|
772
|
-
|
|
|
773
|
-
|
|
|
774
|
-
|
|
|
775
|
-
| `opentunnel setdomain <domain>` | Set default domain for expl command |
|
|
776
|
-
| `opentunnel getdomain` | Show current default domain |
|
|
777
|
-
| `opentunnel cleardomain` | Remove default domain configuration |
|
|
778
|
-
|
|
779
|
-
## Expose Local Command (expl)
|
|
780
|
-
|
|
781
|
-
The simplest way to expose a local port. Starts a local server and creates a tunnel automatically.
|
|
782
|
-
|
|
783
|
-
```bash
|
|
784
|
-
opentunnel expl <port> [options]
|
|
785
|
-
|
|
786
|
-
Options:
|
|
787
|
-
-s, --domain <domain> Server domain (uses default if not specified)
|
|
788
|
-
-b, --base-path <path> Server base path (default: op)
|
|
789
|
-
-n, --subdomain <name> Request specific subdomain
|
|
790
|
-
-p, --protocol <proto> http, https, or tcp (default: http)
|
|
791
|
-
-h, --host <host> Local host (default: localhost)
|
|
792
|
-
-t, --token <token> Authentication token
|
|
793
|
-
--insecure Skip SSL verification
|
|
794
|
-
--server-port <port> Port for local server (default: 443)
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
**Examples:**
|
|
798
|
-
```bash
|
|
799
|
-
# With default domain configured
|
|
800
|
-
opentunnel expl 3000
|
|
801
|
-
|
|
802
|
-
# With explicit domain
|
|
803
|
-
opentunnel expl 3000 -s example.com
|
|
804
|
-
|
|
805
|
-
# With subdomain
|
|
806
|
-
opentunnel expl 3000 -n myapp
|
|
807
|
-
```
|
|
808
|
-
|
|
809
|
-
## Domain Configuration
|
|
810
|
-
|
|
811
|
-
Set a default domain so you don't need to specify `-s` every time:
|
|
812
|
-
|
|
813
|
-
```bash
|
|
814
|
-
# Set default domain
|
|
815
|
-
opentunnel setdomain example.com
|
|
816
|
-
opentunnel setdomain example.com -b op # with custom base path
|
|
817
|
-
|
|
818
|
-
# View current configuration
|
|
819
|
-
opentunnel getdomain
|
|
820
|
-
|
|
821
|
-
# Remove default domain
|
|
822
|
-
opentunnel cleardomain
|
|
823
|
-
```
|
|
824
|
-
|
|
825
|
-
Configuration is stored in `~/.opentunnel/config.json`:
|
|
826
|
-
```json
|
|
827
|
-
{
|
|
828
|
-
"defaultDomain": {
|
|
829
|
-
"domain": "example.com",
|
|
830
|
-
"basePath": "op"
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
```
|
|
834
|
-
|
|
835
|
-
## Quick Command
|
|
836
|
-
|
|
837
|
-
```bash
|
|
838
|
-
opentunnel quick <port> [options]
|
|
839
|
-
|
|
840
|
-
Required:
|
|
841
|
-
-s, --domain <domain> Server domain (e.g., example.com)
|
|
842
|
-
|
|
843
|
-
Options:
|
|
844
|
-
-b, --base-path <path> Server base path (default: op, empty for direct)
|
|
845
|
-
-n, --subdomain <name> Request specific subdomain
|
|
846
|
-
-p, --protocol <proto> http, https, or tcp (default: http)
|
|
847
|
-
-h, --host <host> Local host (default: localhost)
|
|
848
|
-
-t, --token <token> Authentication token
|
|
849
|
-
--insecure Skip SSL verification (self-signed certs)
|
|
850
|
-
--local-server Start a local server (use with -s for your domain)
|
|
851
|
-
--server-port <port> Port for local server (default: 443)
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
## HTTP/TCP Commands
|
|
855
|
-
|
|
856
|
-
```bash
|
|
857
|
-
opentunnel http <port> [options]
|
|
858
|
-
opentunnel tcp <port> [options]
|
|
859
|
-
|
|
860
|
-
Required:
|
|
861
|
-
-s, --domain <domain> Server domain (e.g., example.com)
|
|
862
|
-
|
|
863
|
-
Options:
|
|
864
|
-
-b, --base-path <path> Server base path (default: op)
|
|
865
|
-
-t, --token <token> Authentication token
|
|
866
|
-
-n, --subdomain <name> Custom subdomain
|
|
867
|
-
-h, --host <host> Local host (default: localhost)
|
|
868
|
-
-r, --remote-port <port> Remote TCP port (tcp only)
|
|
869
|
-
--insecure Skip SSL verification
|
|
870
|
-
```
|
|
871
|
-
|
|
872
|
-
## Background Mode
|
|
873
|
-
|
|
874
|
-
Run multiple instances in the background:
|
|
875
|
-
|
|
876
|
-
```bash
|
|
877
|
-
# Start instances
|
|
878
|
-
opentunnel up -d # Default instance
|
|
879
|
-
opentunnel up production -d # Named instance "production"
|
|
880
|
-
opentunnel up staging -d # Named instance "staging"
|
|
881
|
-
|
|
882
|
-
# List running instances
|
|
883
|
-
opentunnel ps
|
|
884
|
-
|
|
885
|
-
# Restart instances
|
|
886
|
-
opentunnel restart # Restart all in current directory
|
|
887
|
-
opentunnel restart production # Restart specific instance
|
|
888
|
-
|
|
889
|
-
# Stop instances
|
|
890
|
-
opentunnel down production # Stop specific instance
|
|
891
|
-
opentunnel down # Stop all instances
|
|
892
|
-
```
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
| Guide | Description |
|
|
62
|
+
|-------|-------------|
|
|
63
|
+
| [Client Guide](docs/client-guide.md) | Complete client usage and options |
|
|
64
|
+
| [Server Guide](docs/server-guide.md) | Server deployment and configuration |
|
|
65
|
+
| [Commands Reference](docs/commands.md) | All CLI commands and options |
|
|
66
|
+
| [Configuration File](docs/configuration.md) | opentunnel.yml reference |
|
|
67
|
+
| [Home Use Guide](docs/home-use-guide.md) | Running from home with port forwarding |
|
|
68
|
+
| [Domain Setup](docs/domain-setup.md) | DNS and SSL configuration |
|
|
69
|
+
| [DuckDNS & Free DNS](docs/duckdns-setup.md) | Free DNS services setup |
|
|
70
|
+
| [Multi-Domain](docs/multi-domain.md) | Multiple domains on one server |
|
|
71
|
+
| [Authentication](docs/authentication.md) | Token-based authentication |
|
|
72
|
+
| [IP Access Control](docs/ip-access-control.md) | Allow/deny IP ranges |
|
|
73
|
+
| [Firewall (Dymo API)](docs/firewall-dymo-api.md) | Fraud detection and bot protection |
|
|
893
74
|
|
|
894
75
|
---
|
|
895
76
|
|
|
896
|
-
|
|
77
|
+
## Architecture
|
|
897
78
|
|
|
898
79
|
```
|
|
899
80
|
┌─────────────────────────────────────────────────────────────────┐
|
|
900
|
-
│ INTERNET
|
|
901
|
-
│
|
|
902
|
-
│ Users access: https://myapp.op.example.com │
|
|
81
|
+
│ INTERNET │
|
|
82
|
+
│ Users access: https://myapp.op.example.com │
|
|
903
83
|
└──────────────────────────────┬──────────────────────────────────┘
|
|
904
84
|
│
|
|
905
85
|
▼
|
|
906
86
|
┌─────────────────────────────────────────────────────────────────┐
|
|
907
|
-
│ OpenTunnel Server
|
|
87
|
+
│ OpenTunnel Server │
|
|
908
88
|
│ (op.example.com) │
|
|
909
|
-
│ │
|
|
910
|
-
│ - Receives HTTPS requests │
|
|
911
89
|
│ - Routes by subdomain │
|
|
912
|
-
│ - Forwards
|
|
90
|
+
│ - Forwards via WebSocket │
|
|
913
91
|
└──────────────────────────────┬──────────────────────────────────┘
|
|
914
|
-
│
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
│ Your Computer │
|
|
92
|
+
│ WebSocket
|
|
93
|
+
▼
|
|
94
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
95
|
+
│ Your Computer │
|
|
919
96
|
│ (behind NAT/firewall) │
|
|
920
|
-
│ │
|
|
921
97
|
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
922
98
|
│ │ Web App │ │ API Server │ │ Database │ │
|
|
923
99
|
│ │ :3000 │ │ :4000 │ │ :5432 │ │
|
|
924
100
|
│ └──────────────┘ └──────────────┘ └──────────────┘ │
|
|
925
|
-
│ │
|
|
926
|
-
│ opentunnel up ← Connects to server, no port forwarding │
|
|
927
101
|
└─────────────────────────────────────────────────────────────────┘
|
|
928
102
|
```
|
|
929
103
|
|
|
930
|
-
**Key points:**
|
|
931
|
-
- Client initiates connection (outbound only)
|
|
932
|
-
- No port forwarding needed on client's router
|
|
933
|
-
- All traffic goes through the server
|
|
934
|
-
- WebSocket keeps connection alive
|
|
935
|
-
|
|
936
104
|
---
|
|
937
105
|
|
|
938
|
-
|
|
106
|
+
## License
|
|
939
107
|
|
|
940
108
|
[Proprietary License](LICENSE) - All rights reserved.
|
|
941
109
|
|
|
942
110
|
- ✅ Personal, educational, and commercial use allowed
|
|
943
111
|
- ❌ No forks or redistribution without permission
|
|
944
|
-
- ❌ No reselling
|
|
112
|
+
- ❌ No reselling without explicit consent
|
|
945
113
|
|
|
946
114
|
Contact FJRG2007 for licensing questions.
|