Skip to content

Commit d16dcbb

Browse files
committed
doc: add docker/nps.md
1 parent 3d740ac commit d16dcbb

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- run: markdown-to-html -s docker/mattermost.md --output build/mattermost.html
2727
- run: markdown-to-html -s docker/mysql.md --output build/mysql.html
2828
- run: markdown-to-html -s docker/nginx.md --output build/nginx.html
29+
- run: markdown-to-html -s docker/nps.md --output build/nps.html
2930
- run: markdown-to-html -s docker/portainer.md --output build/portainer.html
3031
- run: markdown-to-html -s docker/postgres.md --output build/postgres.html
3132
- run: markdown-to-html -s docker/rancher.md --output build/rancher.html

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,10 @@ docker info
672672

673673
[在 docker 中部署 SeaweedFS](docker/seaweedfs/README.md)
674674

675+
### `NPS`
676+
677+
[在 docker 中搭建内网穿透服务器,带WEB管理](docker/nps/README.md)
678+
675679
### `Humpback`
676680

677681
首先创建放持久化数据文件夹,`mkdir -p /opt/app/humpback-web`,里面存放持久化数据文件,会存储站点管理和分组信息,启动后请妥善保存。

docker/nps.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
nps
2+
===
3+
4+
一款轻量级、高性能、功能强大的内网穿透代理服务器。支持tcp、udp、socks5、http等几乎所有流量转发,可用来访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析、内网socks5代理等
5+
6+
### ① 搭建NPS服务端
7+
8+
服务器搭建在拥有公网 `ip=150.106.195.110` 的服务器上。下载配置 [nps/conf](https://github.com/ehang-io/nps/tree/master/conf),将配置放在 `/opt/nps/conf` 目录下,下面我们使用 docker 部署 NPS 服务端:
9+
10+
```bash
11+
# 创建 /opt/nps 目录存放配置文件
12+
mkdir /opt/nps
13+
# 拉取 ffdfgdfg/nps 镜像
14+
docker pull ffdfgdfg/nps
15+
# 运行 nps 容器,配置文件夹 conf 在 /opt/nps/conf 目录下
16+
docker run -d --name=nps --restart=always --net=host -v /opt/nps/conf:/conf ffdfgdfg/nps
17+
# 查看日志
18+
docker logs nps
19+
```
20+
21+
启动之后默认端口 `8080`,通过使用 `http://<你服务器IP>:8080` 访问管理界面。
22+
23+
![](https://user-images.githubusercontent.com/1680273/160862086-1cfc09c2-6b10-4c10-b8d8-094ed10dfd99.png)
24+
25+
使用用户名和密码登陆(默认`admin/123`,正式使用一定要更改,修改 `/opt/nps/conf/nps.conf` 配置文件中的 `web_password`),也可以在这里配置更改默认控制台管理平台端口(`web_port` = `8666`),通道端口更改 `bridge_port=8024`
26+
27+
记得在控制台开放端口,面板**默认端口**`8080`,与客户端**通信端口**`8024`
28+
29+
### ② 添加客户端
30+
31+
<img src="https://user-images.githubusercontent.com/1680273/160861860-8968d67f-ab85-425c-a482-2d1c98055529.png" width="620" />
32+
33+
<img src="https://user-images.githubusercontent.com/1680273/160861528-d52bc738-2023-4df7-812e-76a0af2d4455.png" width="620" />
34+
35+
<img src="https://user-images.githubusercontent.com/1680273/160861122-ac553e4e-d702-4296-a3a6-f2aaea55d973.png" />
36+
37+
注意:客户端命令 `./npc -server=150.106.195.110:8024 -vkey=<唯一验证密钥> -type=tcp` 中的 `唯一验证密钥` 用于客户端安装需要使用
38+
39+
### ③ 客户端安装使用
40+
41+
客户端安装在你需要穿透的内网服务器(电脑)上。
42+
43+
```bash
44+
# 创建 /opt/nps 目录存放配置文件
45+
mkdir /opt/npc
46+
# 拉取 ffdfgdfg/nps 镜像
47+
docker pull ffdfgdfg/npc
48+
# 运行 npc 容器,按提示改好命令,如下图所示
49+
# 唯一验证密钥在管理界面中获取
50+
docker run -d --name=npc --restart=always --net=host ffdfgdfg/npc -server=<ip:port> -vkey=<web界面中显示的密钥> <以及一些其他参数>
51+
# 示例
52+
docker run -d --name=npc --restart=always --net=host ffdfgdfg/npc -server=150.106.195.110:8024 -vkey=<唯一验证密钥>
53+
# 查看日志
54+
docker logs npc
55+
```
56+
57+
服务运行起来,这样客户端就连接到了 NPS 的服务端了
58+
59+
![](https://user-images.githubusercontent.com/1680273/160865479-c0d13263-06c3-4278-944d-6f7d57b5e6fb.png)
60+
61+
### ④ 建立内网穿透隧道
62+
63+
![](https://user-images.githubusercontent.com/1680273/160866018-795d0aff-c0da-4815-bb0e-23c19b8613bb.png)
64+
65+
![](https://user-images.githubusercontent.com/1680273/160866655-6545f5cb-c1dc-403f-a7b3-621c8630a3ef.png)
66+
67+
假设我们要穿透局域网 MySQL 数据库,在 `目标 (IP:端口)` 配置内网 MySQL IP:端口 `192.168.188.222:3306`,在外网访问的端口 `服务端端口` 配置 `33066`
68+
69+
![](https://user-images.githubusercontent.com/1680273/160867661-99b51fa0-e9d5-481c-a707-0cdec55937bb.png)
70+
71+
配置完成之后你可以使用公网 `ip=150.106.195.110` IP 地址 和端口 `33066` 连接到你内网的机器中的数据库。
72+
73+
到这里就完成了,你可以自己继续研究一下更多的功能,也可以看看官方的[说明文档](https://ehang-io.github.io/nps/#/)
74+
75+
### 相关链接
76+
77+
- 官网文档:https://ehang-io.github.io/nps/
78+
- GitHub:https://github.com/ehang-io/nps

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"docker/mattermost.md": "mattermost.html",
1919
"docker/mysql.md": "mysql.html",
2020
"docker/nginx.md": "nginx.html",
21+
"docker/nps.md": "nps.html",
2122
"docker/portainer.md": "portainer.html",
2223
"docker/postgres.md": "postgres.html",
2324
"docker/redis.md": "redis.html",

0 commit comments

Comments
 (0)