frpc配置
学思创
12
文档https://gofrp.org/zh-cn/docs/reference/server-configures/
frpc_full_example.toml
# 此配置文件仅供参考,请不要直接使用此配置运行程序,可能会存在各种问题
# 代理名称将被修改为 {user}.{proxy}
user = "your_name"
# IPv6的地址或主机名必须用方括号包裹
# 例如 "[::1]:80", "[ipv6-host]:http" 或 "[ipv6-host%zone]:80"
# 单独的 serverAddr 字段不需要方括号,例如 serverAddr = "::"
serverAddr = "0.0.0.0"
serverPort = 7000
# 用于穿透NAT的STUN服务器
# natHoleStunServer = "stun.easyvoip.com:3478"
# 首次登录失败是否退出程序,否则持续重连
# 默认 true
loginFailExit = true
# 日志输出:console或文件路径如./frpc.log
log.to = "./frpc.log"
# 日志级别:trace, debug, info, warn, error
log.level = "info"
log.maxDays = 3
# 禁用控制台日志颜色,默认false
log.disablePrintColor = false
auth.method = "token"
# 指定认证信息的附加范围
# 可选值:HeartBeats, NewWorkConns
# auth.additionalScopes = ["HeartBeats", "NewWorkConns"]
# 认证令牌
auth.token = "12345678"
# OIDC客户端ID配置
# auth.oidc.clientID = ""
# auth.oidc.clientSecret = ""
# auth.oidc.audience = ""
# auth.oidc.scope = ""
# auth.oidc.tokenEndpointURL = ""
# OIDC端点附加参数配置
# auth.oidc.additionalEndpointParams.audience = "https://dev.auth.com/api/v2/"
# auth.oidc.additionalEndpointParams.var1 = "foobar"
# 管理接口配置(用于HTTP API控制frpc)
webServer.addr = "127.0.0.1"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "admin"
# 管理界面资源目录,默认内置于frpc
# webServer.assetsDir = "./static"
# 在管理接口中启用pprof
webServer.pprofEnable = false
# 连接服务器的超时时间(秒),默认10秒
# transport.dialServerTimeout = 10
# 保活探测间隔,负数表示禁用
# transport.dialServerKeepalive = 7200
# 预先建立的连接池数量,默认0
transport.poolCount = 5
# 是否启用TCP流多路复用,默认为true,必须与frps一致
# transport.tcpMux = true
# TCP多路复用保活间隔
# 仅在启用tcpMux时有效
# transport.tcpMuxKeepaliveInterval = 30
# 连接服务器的通信协议
# 支持 tcp, kcp, quic, websocket 和 wss,默认tcp
transport.protocol = "tcp"
# 连接服务器时绑定的本地IP,默认空
# 仅当协议为tcp或websocket时有效
transport.connectServerLocalIP = "0.0.0.0"
# 通过代理连接frps的配置(仅tcp协议)
# transport.proxyURL = "http://user:passwd@192.168.1.128:8080"
# transport.proxyURL = "socks5://user:passwd@192.168.1.128:1080"
# transport.proxyURL = "ntlm://user:passwd@192.168.1.128:2080"
# QUIC协议选项
# transport.quic.keepalivePeriod = 10
# transport.quic.maxIdleTimeout = 30
# transport.quic.maxIncomingStreams = 100000
# 是否启用TLS连接,默认true(v0.50.0+)
transport.tls.enable = true
# TLS证书配置
# transport.tls.certFile = "client.crt"
# transport.tls.keyFile = "client.key"
# transport.tls.trustedCaFile = "ca.crt"
# transport.tls.serverName = "example.com"
# 是否禁用自定义TLS首字节(v0.50.0+默认true)
# transport.tls.disableCustomTLSFirstByte = true
# 心跳配置(不建议修改默认值)
# transport.heartbeatInterval = 30
# transport.heartbeatTimeout = 90
# 指定DNS服务器
# dnsServer = "8.8.8.8"
# 需要启动的代理名称
# start = ["ssh", "dns"]
# UDP数据包大小(需与服务器一致)
udpPacketSize = 1500
# 客户端附加元数据
metadatas.var1 = "abc"
metadatas.var2 = "123"
# 包含其他代理配置文件
# includes = ["./confd/*.ini"]
[[proxies]]
# 'ssh'为唯一代理名称
# 如果全局用户不为空,名称将变为 {user}.{proxy}
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
# 带宽限制(支持KB/MB单位)
transport.bandwidthLimit = "1MB"
# 带宽限制模式(client/server)
transport.bandwidthLimitMode = "client"
# 是否加密流量
transport.useEncryption = false
# 是否压缩流量
transport.useCompression = false
# frps监听端口
remotePort = 6001
# 负载均衡组配置
loadBalancer.group = "test_group"
loadBalancer.groupKey = "123456"
# 健康检查配置
healthCheck.type = "tcp"
healthCheck.timeoutSeconds = 3
healthCheck.maxFailed = 3
healthCheck.intervalSeconds = 10
# 代理元数据
metadatas.var1 = "abc"
metadatas.var2 = "123"
# 仪表板注解
[proxies.annotations]
key1 = "value1"
"prefix/key2" = "value2"
[[proxies]]
name = "ssh_random"
type = "tcp"
localIP = "192.168.31.100"
localPort = 22
# remotePort为0时由frps分配随机端口
remotePort = 0
[[proxies]]
name = "dns"
type = "udp"
localIP = "114.114.114.114"
localPort = 53
remotePort = 6002
[[proxies]]
name = "web01"
type = "http"
localIP = "127.0.0.1"
localPort = 80
# HTTP基础认证
httpUser = "admin"
httpPassword = "admin"
# 子域名配置
subdomain = "web01"
customDomains = ["web01.yourdomain.com"]
# 路径匹配
locations = ["/", "/pic"]
# 请求头重写
hostHeaderRewrite = "example.com"
requestHeaders.set.x-from-where = "frp"
responseHeaders.set.foo = "bar"
# HTTP健康检查
healthCheck.type = "http"
healthCheck.path = "/status"
healthCheck.intervalSeconds = 10
healthCheck.maxFailed = 3
healthCheck.timeoutSeconds = 3
healthCheck.httpHeaders=[
{ name = "x-from-where", value = "frp" }
]
[[proxies]]
name = "web02"
type = "https"
localIP = "127.0.0.1"
localPort = 8000
subdomain = "web02"
customDomains = ["web02.yourdomain.com"]
# 代理协议版本
transport.proxyProtocolVersion = "v2"
[[proxies]]
name = "tcpmuxhttpconnect"
type = "tcpmux"
multiplexer = "httpconnect"
localIP = "127.0.0.1"
localPort = 10701
customDomains = ["tunnel1"]
# routeByHTTPUser = "user1"
[[proxies]]
name = "plugin_unix_domain_socket"
type = "tcp"
remotePort = 6003
# if plugin is defined, localIP and localPort is useless
# plugin will handle connections got from frps
[proxies.plugin]
type = "unix_domain_socket"
unixPath = "/var/run/docker.sock"
[[proxies]]
name = "plugin_http_proxy"
type = "tcp"
remotePort = 6004
[proxies.plugin]
type = "http_proxy"
httpUser = "abc"
httpPassword = "abc"
[[proxies]]
name = "plugin_socks5"
type = "tcp"
remotePort = 6005
[proxies.plugin]
type = "socks5"
username = "abc"
password = "abc"
[[proxies]]
name = "plugin_static_file"
type = "tcp"
remotePort = 6006
[proxies.plugin]
type = "static_file"
localPath = "/var/www/blog"
stripPrefix = "static"
httpUser = "abc"
httpPassword = "abc"
[[proxies]]
name = "plugin_https2http"
type = "https"
customDomains = ["test.yourdomain.com"]
[proxies.plugin]
type = "https2http"
localAddr = "127.0.0.1:80"
crtPath = "./server.crt"
keyPath = "./server.key"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
[[proxies]]
name = "plugin_https2https"
type = "https"
customDomains = ["test.yourdomain.com"]
[proxies.plugin]
type = "https2https"
localAddr = "127.0.0.1:443"
crtPath = "./server.crt"
keyPath = "./server.key"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
[[proxies]]
name = "plugin_http2https"
type = "http"
customDomains = ["test.yourdomain.com"]
[proxies.plugin]
type = "http2https"
localAddr = "127.0.0.1:443"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
[[proxies]]
name = "plugin_http2http"
type = "tcp"
remotePort = 6007
[proxies.plugin]
type = "http2http"
localAddr = "127.0.0.1:80"
hostHeaderRewrite = "127.0.0.1"
requestHeaders.set.x-from-where = "frp"
[[proxies]]
name = "plugin_tls2raw"
type = "tcp"
remotePort = 6008
[proxies.plugin]
type = "tls2raw"
localAddr = "127.0.0.1:80"
crtPath = "./server.crt"
keyPath = "./server.key"
[[proxies]]
name = "secret_tcp"
# If the type is secret tcp, remotePort is useless
# Who want to connect local port should deploy another frpc with stcp proxy and role is visitor
type = "stcp"
# secretKey is used for authentication for visitors
secretKey = "abcdefg"
localIP = "127.0.0.1"
localPort = 22
# If not empty, only visitors from specified users can connect.
# Otherwise, visitors from same user can connect. '*' means allow all users.
allowUsers = ["*"]
[[proxies]]
name = "p2p_tcp"
type = "xtcp"
secretKey = "abcdefg"
localIP = "127.0.0.1"
localPort = 22
# If not empty, only visitors from specified users can connect.
# Otherwise, visitors from same user can connect. '*' means allow all users.
allowUsers = ["user1", "user2"]
# frpc role visitor -> frps -> frpc role server
[[visitors]]
name = "secret_tcp_visitor"
type = "stcp"
# the server name you want to visitor
serverName = "secret_tcp"
secretKey = "abcdefg"
# connect this address to visitor stcp server
bindAddr = "127.0.0.1"
# bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
# other visitors. (This is not supported for SUDP now)
bindPort = 9000
[[visitors]]
name = "p2p_tcp_visitor"
type = "xtcp"
# if the server user is not set, it defaults to the current user
serverUser = "user1"
serverName = "p2p_tcp"
secretKey = "abcdefg"
bindAddr = "127.0.0.1"
# bindPort can be less than 0, it means don't bind to the port and only receive connections redirected from
# other visitors. (This is not supported for SUDP now)
bindPort = 9001
# when automatic tunnel persistence is required, set it to true
keepTunnelOpen = false
# effective when keepTunnelOpen is set to true, the number of attempts to punch through per hour
maxRetriesAnHour = 8
minRetryInterval = 90
# fallbackTo = "stcp_visitor"
# fallbackTimeoutMs = 500