This repository has been archived on 2026-08-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
zq/40.归档/3.博客文章/4.3.1.2网络服务搭建/部署一个云服务器为内网nas做穿透.md
T
starmen1265 ea9a5c3b3f 初始提交:知识库工作区
- 00.收件箱
- 01.待办
- 10.项目
- 20.领域
- 30.资源
- 40.归档
- 50.模板
2026-03-03 18:25:09 +08:00

146 lines
4.0 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
服务器系统:Ubuntu 20.04 LTS
# 安装Docker
## 设置Docker仓库
卸载旧版本docker
```shell
sudo apt-get remove docker docker-engine docker.io containerd runc
```
更新apt包索引
```shell
sudo apt-get update
```
安装apt依赖包,用于通过HTTPS来获取仓库
```shell
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
```
添加 Docker 的官方 GPG 密钥
```shell
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
```
验证密钥
```shell
sudo apt-key fingerprint 0EBFCD88
```
设置稳定版仓库
```shell
sudo add-apt-repository \
   "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \
  $(lsb_release -cs) \
  stable"
```
## 安装Docker Engine-Community
更新apt包索引
```shell
sudo apt-get update
```
安装最新版本的 Docker Engine-Community 和 containerd
```shell
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
测试 Docker 是否安装成功
```shell
sudo docker run hello-world
```
# 实用程序
## FinalShell
一个结合了命令行和ftp的工具,还能监控主机状态
https://www.hostbuf.com/t/988.html
## speedtest-x
https://github.com/BadApple9/speedtest-x
https://hub.docker.com/r/badapple9/speedtest-x
speedtest-x用于测试到主机的上传下载速度和延迟,提供一个轻量级的web页面。
拉取镜像
```shell
docker pull badapple9/speedtest-x
```
服务器运行镜像
```shell
docker run -d -p --name speedtest-x1 9001:80 -it badapple9/speedtest-x
```
云服务器的防火墙页面添加规则放行9001端口。
客户端通过网页访问{ip}:9001即可打开测试页面进行测试
## iperf3
https://github.com/esnet/iperf
https://github.com/nerdalert/iperf3
https://hub.docker.com/r/networkstatic/iperf3
https://iperf.fr/iperf-download.php
iperf3用于测试到主机的tcp和udp连接速度,需要用命令行
拉取镜像
```
docker pull networkstatic/iperf3
```
服务器运行镜像
```
docker run -it --rm --name=iperf3-server -p 5201:5201 networkstatic/iperf3 -s
```
云服务器的防火墙页面添加规则放行5201端口,tcp和udp协议。
linux客户端连接
```shell
docker run -it --rm networkstatic/iperf3 -c {yourip}
```
Windows客户端连接
官网下载windows版客户端,进入iperf3.exe所在目录,执行
```bat
iperf3.exe -c {yourip}
```
## frp
https://github.com/fatedier/frp
https://hub.docker.com/r/snowdreamtech/frps
https://hub.docker.com/r/snowdreamtech/frpc
用一个公网服务器和内网连接做内网穿透转发。让任何人可以通过公网IP的端口访问内网的设备端口
服务器拉取镜像
```shell
docker pull snowdreamtech/frps
```
在服务器创建/docker/frps目录。里面编辑frps.ini文件如下
```
[common]
bind_port = 7001
token={你的token}
dashboard_port = 7500
dashboard_user = {你的frp连接状态页面账号}
dashboard_pwd = {你的密码}
```
服务器启动服务镜像
```bash
docker run --restart=always --network host -d -v /docker/frps/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps
```
记得在云服务器防火墙放行7001和7500这两个端口
内网服务器拉取镜像
```
docker pull snowdreamtech/frpc
```
内网服务器创建/docker/frpc目录。里面编辑frpc.ini文件如下
```
[common]
server_addr = {你的服务端ip}
server_port = 7001
token = {你的服务端token}
[xxx]
type = tcp
local_ip = {内网要穿透的ip}
local_port = {内网要穿透的端口}
remote_port = {外网对应的端口}
```
在云服务器防火墙放行外网对应的端口,每个服务编辑一段xxx,名字不可以重复,nas常用应用包括:
* dsm登录 5000/5001
* calibre 图书馆
* plex影视播放
* kavita 漫画库
* calendar 日历
* RssHub
* typecho
内网服务器运行镜像
```bash
docker run --restart=always --network host -d -v /docker/frpc/frpc.ini:/etc/frp/frpc.ini --name frpc snowdreamtech/frpc
```
浏览器打开{服务器ip}:7500,输入账户密码,查看连接状态