frp 内网穿透(http/https), windows 版本实验
前提条件
- 一台有公网ip的服务器
Server: 我自己的公网服务器是linux系统
Client: 本地是window11 系统
- 添加测试的域名解析
官网地址
下载安装包
https://github.com/fatedier/frp/releases
分别下载如图所示安装包
Server端安装
- 解压
frp_0.62.1_linux_amd64.tar.gz
tar -xzvf frp_0.62.1_linux_amd64.tar.gz
- 修改配置文件
bindPort = 7000
vhostHTTPPort = 8888
vhostHTTPSPort = 9999
此处启动了 http 端口8888,https 端口9999
- 启动服务
./frps -c ./frps.toml
Client端安装
- 解压
frp_0.62.1_windows_amd64.zip
myssl 文件夹是我自己创建的, 里面的证书也是我自己的
http 映射
-
修改配置文件
frpc.toml
serverAddr = "47.103.206.85" serverPort = 7000 [[proxies]] name = "web" type = "http" localPort = 8080 customDomains = ["local.majingjing.cn"]
此处启动了 http 端口8080
-
启动http映射服务
# 开启http映射 .\frpc.exe -c .\frpc.toml
-
验证
https 映射
-
修改配置文件
frpc_https.toml
serverAddr = "47.103.206.85" serverPort = 7000 [[proxies]] name = "test_htts2http" type = "https" customDomains = ["local.majingjing.cn"] [proxies.plugin] type = "https2http" localAddr = "127.0.0.1:8080" # HTTPS 证书相关的配置 crtPath = "./myssl/cert.crt" keyPath = "./myssl/cert.key" hostHeaderRewrite = "127.0.0.1" requestHeaders.set.x-from-where = "frp"
此处启动了 http 端口8080,装载了证书插件
-
启动https映射服务
# 开启https映射 .\frpc.exe -c .\frpc_https.toml
-
验证
身份认证
目前 frpc 和 frps 之间支持两种身份验证方式,token 和 oidc,默认为 token。这些认证方式允许您验证客户端与服务端之间的通信,并确保只有授权用户能够建立连接。
Token
Token 身份认证是一种简单的身份认证方式,只需要在 frp 的客户端 frpc 和服务端 frps 配置文件中配置相同的 token 即可。
配置示例
# frps.toml
bindPort = 7000
auth.token = "abc"
# frpc.toml
auth.token = "abc"