假定在内网部署了dify服务,想让该服务在外网也能访问
实现原理:
利用frp实现tcp隧道,将内网的Dify发布到公有云主机。
利用公有云域名解析和公网ip的固定性,实现稳定的内网Dify发布到外网功能
文档地址:https://gofrp.org/zh-cn/docs/
-
准备一台阿里云ECS服务器,且需要一个公网IP(假定IP地址为:
111.63.65.247) -
申请一个域名(假定域名为:testdomain.com),配置域名指向
添加A记录,主机记录:dify,记录值为IP地址 -
修改安全组
允许任意来源访问服务器的tcp 60700 60800端口,实现开放frp端口与Dify互联的目的 -
在ECS服务器中安装frp服务端
wget https://github.com/fatedier/frp/releases/tag/v0.58.1/https://github.com/fatedier/frp/releases/download/v0.58.1/frp_0.58.1_linux_amd64.tar.gz`
tar zxf frp_0.58.1_linux_amd64.tar.gzcd frp_0.58.1_linux_amd64
#修改配置文件
cat > frps.toml <<EOF
bindPort = 60700
vhostHTTPPort=60800
EOF#启动frps服务端
./frps -c frps.toml -
在Windows中安装frp客户端
https://github.com/fatedier/frp/releases/download/v0.58.1/frp_0.58.1_windows_amd64.zip
下载并解压缩,修改配置文件frpc.toml
serverAddr = "111.63.65.247"
serverPort = 60700
[[proxies]]
name = "dify"
type = "http"
localPort = 80
custom_domains = ["dify.testdomain.com"]
启动frps客户端
frpc -c frpc.tom
访问测试站点:http://dify.testdomain.com:60800
frp参数文档:https://gofrp.org/zh-cn/docs/examples/vhost-http/