宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

威联通NAS配置frp实现内网穿透访问:

一、条件:

1.阿里云服务器1台,Ubuntu系统

2.威联通NAS1台或家庭主机1台

二、阿里云服务端配置:

1.安装docker

# 安装docker
apt-get install docker-io
# 检查是否成功安装
docker version
# 设置成开机自动启动
service docker start

2.查找frps(frp服务端)镜像

# 查找镜像
docker search frps
# 拉取snowdreamtech的镜像
docker pull snowdreamtech/frps
# 创建服务端配置文件,配置文件为ini格式
cd /etc/frp
vi frps.ini
# 运行
docker run --network host -d -v /etc/frp/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps

2.frps.ini服务器端配置文件

# [common] 部分不可缺少
[common]
# bind_addr 必须包含IP地址 或者 域名 主机名
# 用方括号括起来,例如 "[::1]:80", "[ipv6-host]:http" 或 "[ipv6-host%zone]:80"
bind_addr = 0.0.0.0
bind_port = 7000
# udp端口有助于 udp 内网穿透
bind_udp_port = 7001
# 用于 kcp 协议的 udp 端口,可以与'bind_port'相同
# 如果未设置,则以 frps 禁用 kcp
kcp_bind_port = 7000
# 指定要侦听的地址代理,默认值与 bind_addr 相同,127.0.0.1仅限本地、0.0.0.0为不限地址
# proxy_bind_addr = 127.0.0.1
# 如果要支持虚拟主机,则必须设置用于侦听的http端口(可选)
# vhost_http_port 参数来设置 HTTP 访问端口,此处示例:8090
# 注意:http 端口和 https 端口可以与 bind_port 相同
vhost_http_port = 80
vhost_https_port = 443
# vhost http 服务器的响应标头超时(秒),默认为60s
# vhost_http_timeout = 60
# 指定 仪表盘控制界面 Dashboard 的监听的 IP 地址 //0.0.0.0 为所以IP均可访问
# 指定 仪表盘控制界面 dashboard_port 的监听的端口,默认为 7500
dashboard_addr = 0.0.0.0
dashboard_port = 7500
# 指定访问 仪表盘控制界面 Dashboard 的登录用户名、用户密码,如果未设置,则两个默认值均为admin
dashboard_user = xxxx
dashboard_pwd = xxxx
# dashboard assets directoryonly for debug mode)
# assets_dir = ./static
# 日志文件路径
log_file = ./frps.log
# 设置日志显示级别{debug, info, warn, error)
log_level = info
# 设置日志最大天数
log_max_days = 3
# disable log colors when log_file is console, default is false
disable_log_color = false
# FRP 身份验证
token = xxxxx
# heartbeat configure 不建议修改默认值
# heartbeat_timeout 的默认值为90
# heartbeat_timeout = 90
# 端口白名单
# 为了防止端口被滥用,可以手动指定允许哪些端口被使用,在 frps.ini 中通过 allow_ports 来指定:
# 只允许 frpc 绑定您列出的端口,如果不进行任何设置,则没有任何限制
# allow_ports 可以配置允许使用的某个指定端口或者是一个范围内的所有端口,以 , 分隔,指定的范围以 - 分隔。
allow_ports = 2000-3000,3001,3003,4000-50000
# 每个代理中的 pool_count 超过最大值,最大链接池,每个代理预先与后端服务器建立起指定数量的最大链接数
# frps.ini 中设置每个代理可以创建的连接池上限,避免大量资源占用
max_pool_count = 5
# 每个客户端可以使用的最大端口数,默认值为0表示没有限制
max_ports_per_client = 0
# 如果 subdomain_host 不为空,则可以在frpc的配置文件中将类型设置为http或https时设置子域
# subdomain_host 参数来设置 Web 服务增加自定义二级域名
# 当子域时,路由使用的主机是 test.frps.com
subdomain_host = frps.com
# 如果使用 tcp 流多路复用,则默认为true
tcp_mux = true
# 定制 HTTP 请求的 404 页面
# custom_404_page = /path/to/404.html

3.frpc.ini客户端配置文件

[common]
server_addr = xxxx
server_port = 7000
token = xxxx
[ssh-qnap]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6022
use_encryption = true
use_compression = true
[qnap-web]
type = tcp
local_ip = 127.0.0.1
local_port = 8080
remote_port = 6080
use_encryption = true
use_compression = true
[Gogs-web]
type = tcp
local_ip = 127.0.0.1
local_port = 32768
remote_port = 32768
use_encryption = true
use_compression = true
[odoo-web]
type = tcp
local_ip = 127.0.0.1
local_port = 18069
remote_port = 18069
use_encryption = true
use_compression = true

4.运行客户端docker

docker run --network host -d -v /etc/frp/frpc.ini:/etc/frp/frpc.ini --name frpc snowdreamtech/frpc