搭建内网穿透

发布时间 2023-08-16 15:06:07作者: 江南烟雨行舟

搭建内网穿透

通过在具有公网 IP 的节点上部署 frp 服务端, 可以轻松地将内网服务穿透到公网. GitHub 地址: https://github.com/fatedier/frp.

下载和解压:

wget https://github.com/fatedier/frp/releases/download/v0.47.0/frp_0.47.0_linux_amd64.tar.gz
tar -zxvf frp_0.47.0_linux_amd64.tar.gz
cd frp_0.47.0_linux_amd64

服务端配置:

[common]
# 服务端监听端口, 接收 frpc 的连接
bind_port = 9488
vhost_http_port = 80
vhost_https_port = 443
# allow_ports = 8000-90000

# 令牌
authentication_method = token
token = 12345678

# 连接池大小
max_pool_count = 5
# 限制单个客户端最大同时存在的代理数, 0 表示没有限.
max_ports_per_client = 0

# 服务监控配置
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = admin
pprof_enable = false
# {dashboard_addr}:{dashboard_port}/metrics
enable_prometheus = true

# 日志配置
log_file = ./frps.log
log_level = info
log_max_days = 3
detailed_errors_to_client = true

客户端 HTTP 配置:

[common]
server_addr = X.X.X.X
server_port = 7000
token = 12345678

[web]
type = http
local_ip = 127.0.0.1
local_port = 8080
custom_domains = 

客户端 HTTPS 配置:

[common]
server_addr = X.X.X.X
server_port = 7000
token = 12345678

# 如果本地服务也支持 https 可以使用 https2https 插件
[https2http]
type = https
custom_domains = 

plugin = https2http
plugin_local_addr = 127.0.0.1:8080
plugin_crt_path = ./server.crt
plugin_key_path = ./server.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

后台运行

$ nohup ./frps -c ./frps.ini &

nps

GitHub 地址: https://github.com/ehang-io/nps

mkdir nps_0.26.10
cd nps_0.26.10
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_server.tar.gz
tar -zxvf linux_amd64_server.tar.gz

安装和启动:

sudo ./nps install
sudo nps start
# 停止
sudo nps stop
  • 访问服务端 ip:web 服务端口(默认为 8080)
  • 使用用户名和密码登陆(默认 admin/123,正式使用一定要更改)

安装路径:/etc/nps,日志文件:/var/log/nps.log。