大家好,我是雄雄,欢迎关注微信公众号:雄雄的小课堂。
前言
之前配置的好好的frp
,结果到用的时候不能用了,直接影响了我早上的一堆rss订阅源
不能用,群里的新闻简报也没有正常推送,今天又翻出来捋了一下,发现之前配置的都忘记了,重新理理之后在这里做个备忘录吧。
配置如下
如题所示,配置代码如下:
# frp内网穿透反向代理配置
server {
listen 80;
server_name *.xxx.xyz; #泛域名
location / {
proxy_pass http://xxx.xyz:8600;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
上面的配置,需要注意这么几个地方:
-
泛域名:
*.xxx.com
,这个你需要在你的域名下面解析一条泛域名,记录为:*.xxx.com
,记录值为你frps
(内网穿透公网)的ip
-
8600端口,是你在
frps.toml
文件里面配置的vhostHTTPPort
端口,简单点来说,所有请求你泛域名的8600端口,都会直接转发到frpc
客户端上。比如我现在想要请求:
nas.xxx.com:8600
,我只需要在浏览器里面输入nas.xxx.com
即可;想要请求:docker.xxx.com:8600
,我只需要在浏览器里面输入docker.xxx.com
即可;因为我在nginx
已经配置了转发。
frps.toml服务端配置
附加,`frps.toml`的配置文件:
# 云服务器和内网工作站之间的连接建立端口
bindPort = 8601
# http域名的端口
vhostHTTPPort = 8600
# 通讯口令,写复杂一些
auth.token = "XKhjneeTEbJbFGLIZJXxxxxxxxxxxxXOnPoucZsQIrBK"
webServer.addr = "0.0.0.0"
webServer.port = 8602
webServer.user = "xxxx"
webServer.password = "xxxxx@2024.@"
# frp日志配置
log.to = "/var/local/frps.log"
log.level = "info"
frpc客户端配置
在客户端我们就可以这么配置,来区分不同的域名访问不同的端口啦:
serverAddr = "公网ip"
serverPort = 8601
webServer.addr = "0.0.0.0"
webServer.port = 8602
webServer.user = "xxxx"
webServer.password = "xxxxx@2024.@"
auth.method = "token"
auth.token = "XKhjneeTEbJbFGLIZJXxxxxxxxxxxxXOnPoucZsQIrBK"
[[proxies]]
name = "qunhui-nas"
type = "http"
localIP = "192.168.1.100"
localPort = 5000
customDomains = ["nas.xxx.com"]
[[proxies]]
name = "qunhui-tongbu"
type = "tcp"
localIP = "192.168.1.100"
localPort = 6690
remotePort = 6690
[[proxies]]
name = "qunhui-ssh"
type = "tcp"
localIP = "192.168.1.100"
localPort = 45322
remotePort = 8606
[[proxies]]
name = "qunhui-file"
type = "http"
localIP = "192.168.1.100"
localPort = 5005
customDomains = ["file.xxx.com"]
[[proxies]]
name = "qunhui-dockage"
type = "http"
localIP = "192.168.1.100"
localPort = 8608
customDomains = ["docker.xxx.com"]
[[proxies]]
name = "qunhui-wxrss"
type = "http"
localIP = "192.168.1.100"
localPort = 4000
customDomains = ["wxrss.xxx.com"]
[[proxies]]
name = "qunhui-rsshub"
type = "http"
localIP = "192.168.1.100"
localPort = 1200
customDomains = ["rsshub.xxx.com"]
[[proxies]]
name = "qunhui-beikong"
type = "http"
localIP = "192.168.1.100"
localPort = 5555
customDomains = ["beikong.xxx.com"]
然后就可以啦,本来之前配置好了,结果今天又不行了,然后之前配置的都忘记了,这下备份了应该不会忘记了。