Expose web services on internal servers through a cloud relay with a dashboard and reverse proxy over WebSocket tunnels.
Project description
Kite - 反向隧道服务注册系统
将内网服务器上的 Web 服务通过云服务器暴露给外部访问。
适用场景
┌─────────┐ WebSocket ┌─────────────┐ HTTP ┌─────────┐
│ 内网服务器├──────────────►│ 云服务器 X │◄─────────│ 浏览器 │
│ A/B/C │ │ kite-server │ └─────────┘
│(kite-client) │ Dashboard │
└─────────┘ │ + 反向代理 │
└─────────────┘
- 内网服务器 A/B/C 无法从外部直接访问
- A/B/C 可以主动连接云服务器 X,反之不行
- 需要通过 X 访问 A/B/C 上的 Web 服务
安装
Python 3.8+,唯一依赖 aiohttp:
pip install aiohttp
使用
1. 在云服务器 X 上启动 Server
python kite_server.py --port 8080
可选参数:
| 参数 | 默认值 | 说明 |
|---|---|---|
--host |
0.0.0.0 |
监听地址 |
--port |
8080 |
监听端口 |
2. 在内网服务器上启动 Client
假设 A 上有一个运行在 3000 端口的 Web 服务:
python kite_client.py --server ws://X:8080/ws --port 3000 --name "my-api"
可选参数:
| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
--server |
是 | - | Server 的 WebSocket 地址 |
--port |
是 | - | 本地 Web 服务端口 |
--name |
否 | 主机名:端口 |
服务显示名称 |
3. 访问
- Dashboard:浏览器打开
http://X:8080,查看所有已注册服务 - 代理访问:点击服务名称,或直接访问
http://X:8080/proxy/{service_id}/
工作原理
- Client 通过 WebSocket 连接 Server,注册本地服务信息
- Server 记录服务并在 Dashboard 展示
- 浏览器访问代理路径时,Server 将 HTTP 请求通过 WebSocket 转发给 Client
- Client 向本地服务发起请求,将响应原路返回
- Client 断线后自动重连(指数退避,1s → 30s)
示例
在同一台机器上快速体验:
# 终端 1:启动 Server
python kite_server.py --port 34321
# 终端 2:启动一个测试 Web 服务
python -m http.server 9000
# 终端 3:启动 Client,将 9000 端口暴露到 Server
python kite_client.py --server ws://localhost:8080/ws --port 9000 --name "file-server"
# 浏览器打开 http://localhost:8080 查看 Dashboard,点击服务即可访问
多服务注册
每个 Web 服务启动一个 Client 实例即可:
# Server A
python kite_client.py --server ws://X:8080/ws --port 3000 --name "api-server"
python kite_client.py --server ws://X:8080/ws --port 8888 --name "jupyter"
# Server B
python kite_client.py --server ws://X:8080/ws --port 5000 --name "flask-app"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kite_strings-0.1.1.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kite_strings-0.1.1.tar.gz.
File metadata
- Download URL: kite_strings-0.1.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda7e00a9d2b3a0650bf38b24075494ef041f332b42462da12af23592bb9cdf8
|
|
| MD5 |
f14d65b1455c911d31364a9e3a21b422
|
|
| BLAKE2b-256 |
8051c0030600c0a429b784d673e02f76464bb69280c0732ee0e508fbfccd035d
|
File details
Details for the file kite_strings-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kite_strings-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c70ab2ef149d341fe4ffc4e714e10e9d7e30adb4f3c25bb5fb305a8e48620b7
|
|
| MD5 |
d957f5987abb5e28d1fe30199086ee4b
|
|
| BLAKE2b-256 |
2655f5c1ea8e7292feb16927e630b95ac161a569dc5e010de637459a64e1aaf5
|