|
| 1 | +# Example: proxy-with-sni |
| 2 | + |
| 3 | +This example shows a SSH WebSocket tunneling setup over CDN proxy using `tunn` with TLS Server Name Indication (SNI). |
| 4 | + |
| 5 | +## Config file |
| 6 | + |
| 7 | +The sample file is `config.json`. |
| 8 | + |
| 9 | +```json |
| 10 | +{ |
| 11 | + "host": "bug-host.com", |
| 12 | + "port": 443, |
| 13 | + "auth": { |
| 14 | + "user": "ssh-username", |
| 15 | + "pass": "ssh-password" |
| 16 | + }, |
| 17 | + "local": { |
| 18 | + "type": "http", |
| 19 | + "port": 8080 |
| 20 | + }, |
| 21 | + "payload": "GET / HTTP/1.1\r\nHost: vps-server.com\r\nUpgrade: websocket\r\n\r\n", |
| 22 | + "timeout": 30, |
| 23 | + "tls": { |
| 24 | + "sni": "vps-server.com" |
| 25 | + } |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +## What this config does |
| 30 | + |
| 31 | +- `host`: connects to the remote server at `bug-host.com`. |
| 32 | +- `port`: connects over port `443`, so the remote connection uses TLS. |
| 33 | +- `auth.user`: SSH username used by the tunnel. |
| 34 | +- `auth.pass`: SSH password used by the tunnel. |
| 35 | +- `local.type`: local listener type; `http` means `tunn` exposes an HTTP proxy locally. |
| 36 | +- `local.port`: local proxy listens on port `8080`. |
| 37 | +- `payload`: raw HTTP request sent to the remote host to initiate a WebSocket connection. |
| 38 | + - `Host: vps-server.com` is the host name used in the WebSocket upgrade request. |
| 39 | + - `Upgrade: websocket` requests a WebSocket tunnel. |
| 40 | +- `timeout`: connection timeout in seconds. |
| 41 | +- `tls.sni`: sets the TLS Server Name Indication header to `vps-server.com`. |
| 42 | + - This is used when the remote TLS server expects a specific hostname during the handshake. |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +Run `tunn` with this config: |
| 47 | + |
| 48 | +```bash |
| 49 | +tunn -config examples/proxy-with-sni/config.json |
| 50 | +``` |
| 51 | + |
| 52 | +Then point your local HTTP proxy client to `127.0.0.1:8080`. |
0 commit comments