frp: 配置指南

frp 配置
更新于: 2023-10-23 20:46:25

安装

因为是 go 语言开发的,下载解压即可

最终项目: https://github.com/afeiship/frp

  • 服务端 (外网服务器)
  • 客户端( 我们自己的电脑 )
# linux 端
https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_linux_amd64.tar.gz
# mac 端
https://github.com/fatedier/frp/releases/download/v0.51.3/frp_0.51.3_darwin_amd64.tar.gz

步骤

  1. 域名范解析
  2. 添加记录,生成范解析证书
  3. 配置 server
  4. 配置 client

域名解析

域名范解析
cerbot https证书生成

frp server

frps -c frps.ini

[common]
bind_port = 7000
vhost_http_port = 80
vhost_https_port = 443
token = 123123
subdomain_host = frp.js.work

frp client

frpc -c frpc.ini

[common]
server_addr = 103.96.148.144
server_port = 7000
token = 123123

[web]
type = http
local_ip = 127.0.0.1
local_port = 3000
subdomain = t1

[test_htts2http]
type = https
; custom_domains = t1.frp.js.work
subdomain = t1
plugin = https2http
plugin_local_addr = 127.0.0.1:3000
plugin_crt_path = ./ssl/frp.js.work/fullchain1.pem
plugin_key_path = ./ssl/frp.js.work/privkey1.pem
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

cheatsheet

各种常用的配置场景,可利用 mkcert 生成域名证书。

  1. 电脑安装: mkcert -install
  2. 特定的域名: mkcert t1.frt.saybot.net
[common]
server_addr = frp.saybot.net
server_port = 7000
token = YOUR_TOKEN
场景client
http(单域名)
[web]
type = http
local_ip = 127.0.0.1
local_port = 3000
custom_domains = frp.saybot.net
http(泛域名)
[web]
type = http
local_ip = 127.0.0.1
local_port = 3000
subdomain = t1

https(单域名)

http://frp.saybot.net

[test_htts2http]
type = https
custom_domains = frp.saybot.net
plugin = https2http
plugin_local_addr = 127.0.0.1:3000
plugin_crt_path = ./ssl/127.0.0.1.pem
plugin_key_path = ./ssl/127.0.0.1-key.pem
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

https(泛域名)

https://t1.frp.saybot.net

[test_htts2http]
type = https
subdomain = t1
plugin = https2http
plugin_local_addr = 127.0.0.1:3000
plugin_crt_path = ./ssl/127.0.0.1.pem
plugin_key_path = ./ssl/127.0.0.1-key.pem
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

参考