2025-02-03
编程
00
请注意,本文编写于 131 天前,最后修改于 125 天前,其中某些信息可能已经过时。

目录

frp安装指南
包管理器安装frp
ubuntu/debain
centos
macos
手动安装frp
下载frp
运行frp
docker安装(推荐)
frp配置
服务端配置
客户端配置
frp查看面板

frp端口映射的安装指南和使用教程

frp安装指南

包管理器安装frp

注意

安装后需要手动编辑/etc/frp/frpc.toml或者/etc/frp/frps.toml,随后启动frp服务
frpc -c /etc/frp/frpc.toml
frpc -c /etc/frp/frps.toml

ubuntu/debain

sudo apt update #更新包管理器
sudo apt install frpc #安装客户端
sudo apt install frps #安装服务端

centos

sudo yum update #更新包管理器
sudo yum install frpc #安装客户端
sudo yum install frps #安装服务端

macos

brew install frpc #安装客户端
brew install frps #安装服务端

手动安装frp

ubuntu&centos&unix&win通用

下载frp

frp发行版本页面下载发行版解压到对应文件夹即可使用

运行frp

可以同时开启多个进程,且docker用户可以省略

服务端运行

nohup ./frps -c ./frps.toml > frps.log 2>&1 &

客户端运行

nohup ./frpc -c ./frpc.toml > frpc.log 2>&1 &

提示

在windows的运行会有些不同

docker安装(推荐)

0.52.0版本之前(ini配置文件)

docker run --restart=always --network host -d -v /frp/frps.ini:/etc/frp/frps.ini --name frps snowdreamtech/frps

0.52.0版本之后(toml配置文件,推荐)

docker run --restart=always --network host -d -v /etc/frp/frps.toml:/etc/frp/frps.toml --name frps snowdreamtech/frps

frp配置

服务端配置

bindPort = 7000 auth.method = "token" auth.token = "token123" webServer.addr = "0.0.0.0" webServer.port = 7500 webServer.user = "admin" webServer.password = "admin"

客户端配置

[common] # 这里填写 A 机器的 IP 或者域名 server_addr = 100.13.*.* # 填写 A 机器开放的 frp 服务端口,也就是 frps.ini 配置文件中 bind_port 的值 server_port = 7000 # 填写token token="token123" [web1] # 依然支持 http 访问 type = tcp # 本地的ip local_ip = 127.0.0.1 # 本地 Web 服务的端口 local_port = 10000 # vps的10001映射到本地的10000 remote_port = 10001 [walterlv_example_http] # 依然支持 http 访问 type = http # 本地 Web 服务的端口 local_port = 10000 # 需要反向代理的域名(当访客通过此域名访问 A 机器时,才会将请求反向代理到此 Web 服务) custom_domains = example.walterlv.com [walterlv_example] # 配置 https 访问 type = https # 本地 Web 服务的端口(与前面的配置一样,都对应同一个 Web 服务) local_port = 10000 # 需要反向代理的域名(当访客通过此域名访问 A 机器时,才会将请求反向代理到此 Web 服务) custom_domains = example.walterlv.com # 接下来的配置是支持 https 的重点配置 # 配置插件,将 https 请求转换成 http 请求后再发送给本地 Web 服务程序 plugin = https2http # 转换成 http 后,发送到本机的 10000 端口 plugin_local_addr = 127.0.0.1:10000 # 可能是 frp 的 Bug?这里必须写成 127.0.0.1,稍后解释 plugin_host_header_rewrite = 127.0.0.1 # 指定代理方式为 frp plugin_header_X-From-Where = frp # 指定成你在前面部分导出的证书的路径 plugin_crt_path = C:/Samples/_.walterlv.com_chain.crt plugin_key_path = C:/Samples/_.walterlv.com_key.key

frp查看面板

通过frps.toml中设置的ip和port,直接访问dashboard即http://ip:port ,输入账号密码,即可查看已被穿透的端口