查看系统cpu架构
1 2 3 4 5
| lscpu
dpkg --print-architecture
|
公网服务器下载frp
1
| wget https://github.com/fatedier/frp/releases/download/v0.58.1/frp_0.58.1_linux_amd64.tar.gz
|
解压命令
1
| tar -zxvf frp_0.58.1_linux_amd64.tar.gz
|
编辑frps.toml文件
1
| cd frp_0.58.1_linux_amd64 && nano frps.toml
|
frps.toml
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
bindPort = 7000
vhostHTTPPort = 8080 vhostHTTPSPort = 8443
|
局域网设备下载frp
1
| wget https://github.com/fatedier/frp/releases/download/v0.58.1/frp_0.58.1_linux_arm64.tar.gz
|
解压命令
1
| tar -zxvf frp_0.58.1_linux_arm64.tar.gz
|
编辑frpc.toml文件
1
| cd frp_0.58.1_linux_arm64 && nano frpc.toml
|
frpc.toml
通用部分配置
1 2 3 4 5 6 7 8 9 10
|
serverAddr = "88.218.238.208"
serverPort = 7000
|
远程 ssh 配置
1 2 3 4 5 6 7 8
|
[[proxies]] name = "ssh" type = "tcp" localIP = "127.0.0.1" localPort = 22 remotePort = 6000
|
http 或 https 代理配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
[[proxies]] name = "http80" type = "http" localPort = 80
customDomains = ["w1.abc.com"] locations = ["/"]
[[proxies]] name = "http81" type = "http" localPort = 81
customDomains = ["w1.abc.com"] locations = ["/news", "/about"]
[[proxies]] name = "https443" type = "https" localPort = 443
customDomains = ["w1.abc.com"]
[[proxies]] name = "https444" type = "https" localPort = 444
customDomains = ["w2.abc.com"]
|
tcp 代理配置
注意:每个tcp代理的 remotePort 不能一样
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [[proxies]] name = "tcp80" type = "tcp" localIP = "127.0.0.1" localPort = 80
remotePort = 6080
[[proxies]] name = "tcp443" type = "tcp" localIP = "127.0.0.1" localPort = 443
remotePort = 6443
|
frp实现的负载均衡
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
[[proxies]] name = "device001" type = "tcp" localIP = "127.0.0.1" localPort = 80
remotePort = 6081 loadBalancer.group = "web"
[[proxies]] name = "device002" type = "tcp" localIP = "127.0.0.1" localPort = 80
remotePort = 6081 loadBalancer.group = "web"
|
http 转 https 插件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
[[proxies]] name = "plugin_htts2http" type = "https" customDomains = ["test.abc.com"] [proxies.plugin] type = "https2http" localAddr = "127.0.0.1:80"
crtPath = "/www1/web/ssl/abc.com/cert.pem" keyPath = "/www1/web/ssl/abc.com/key.pem"
|
Unix 域套接字插件
1 2 3 4 5 6 7 8 9 10 11 12
|
[[proxies]] name = "plugin_unix_domain_socket" type = "tcp" remotePort = 6082
[proxies.plugin] type = "unix_domain_socket"
unixPath = "/var/run/docker.sock"
|
命令行运行
1 2 3 4 5
| ./frps -c ./frps.toml
./frpc -c ./frpc.toml
|
docker 容器中运行
1 2 3 4 5
| docker run -itd --restart=always --network host -v /etc/frp/frps.toml:/etc/frp/frps.toml --name frps snowdreamtech/frps
docker run -itd --restart=always --network host -v /etc/frp/frpc.toml:/etc/frp/frpc.toml --name frpc snowdreamtech/frpc
|