欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 建筑 > 新版frp-0.61.0 实现泛解析域名穿透 以及 https启用

新版frp-0.61.0 实现泛解析域名穿透 以及 https启用

2025/3/25 16:22:05 来源:https://blog.csdn.net/do_you_like_van_game/article/details/146413153  浏览:    关键词:新版frp-0.61.0 实现泛解析域名穿透 以及 https启用

需要在公网服务器的域名解析平台 泛域名 *.aa.com 解析到frp 公网服务器的ip x.x.x.x

对于frpc.toml 文件的 serverAddr 绑定的ip 需要公网服务器放行 bindPort 对于的端口

frpc.toml serverPort  对于的的是 frps.toml bindPort 端口

frps.toml

bindPort = 7000
vhostHTTPPort = 80
vhostHTTPSPort = 443
frppath="/data/frp/frp_0.61.0_linux_amd64"port=7000fprsStart(){if [ -d ${frppath} ];thenecho ""elseecho "${frppath}目录不存在"exitfiecho "进入${frppath}目录"cd ${frppath}nohup ./frps -c ./frps.toml > frps.log 2>&1 &exit
}fprsStop(){#根据端口号查询对应的pidpid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{ print $1 }');#杀掉对应的进程,如果pid不存在,则不执行if [  -n  "$pid"  ]thenkill  -9  $pid;echo "${port}端口对应的进程号${pid}被杀死"elseecho "${port}端口未启动"fi
}frpReStart(){fprsStopsleep 2sfprsStart}commport(){#根据端口号查询对应的pidpid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{ print $1 }');#杀掉对应的进程,如果pid不存在,则不执行if [  -n  "$pid"  ]thenecho "${port}端口对应的进程号${pid}"elseecho "${port}端口未启动"fi
}sele(){commport
}helpTxt(){echo "-----------------------------"echo "      start     启动frps        "echo "      stop      关闭frps        "echo "      restart   重启frps        "# echo "      2      启动frpc        "# echo "      3      关闭frpc        "echo "      sele      端口运行情况        "# echo "      exit   退出        "echo "-----------------------------"
}case "$1" in"start")fprsStart;;"stop")fprsStop;;"restart")frpReStart;;"sele")sele;;    *)helpTxt;;
esac

内网机器的nginx配置ssl证书,至于ssl证书自己去搞,宝塔获取也好,免费的也好,很好弄的

server {# 服务器端口使用443,开启ssl, 这里ssl就是上面安装的ssl模块listen       443 ssl;# 域名,多个以空格分开server_name  *.aa.com;# ssl证书地址ssl_certificate     /usr/local/nginx/cert/ssl.pem;  # pem文件的路径ssl_certificate_key  /usr/local/nginx/cert/ssl.key; # key文件的路径# ssl验证相关配置ssl_session_timeout  5m;    #缓存有效期ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;    #加密算法ssl_protocols TLSv1 TLSv1.1 TLSv1.2;    #安全链接可选的加密协议ssl_prefer_server_ciphers on;   #使用服务器端的首选算法location / {root   html;index  index.html index.htm;}
}

https 最重要的是

[[proxies]]
name = "nginx"
type = "https"
localIP = "192.168.1.33"
localPort = 443
customDomains = ["*.aa.com"]

frpc.toml

serverAddr = "x.x.x.x"
serverPort = 7000webServer.addr = "0.0.0.0"
webServer.port = 7000
webServer.user = "admin"
webServer.password = "admin"[[proxies]]
name = "web"
type = "http"
localIP = "192.168.1.34"
localPort = 9100
customDomains = ["mqtt.aa.com"][[proxies]]
name = "mqtt"
type = "tcp"
localIP = "192.168.1.33"
localPort = 1883
remotePort = 1883[[proxies]]
name = "nginx"
type = "https"
localIP = "192.168.1.33"
localPort = 443
customDomains = ["*.aa.com"]
frppath="/data/frp/frp_0.61.0_linux_amd64"port=7000fprsStart(){if [ -d ${frppath} ];thenecho ""elseecho "${frppath}目录不存在"exitfiecho "进入${frppath}目录"cd ${frppath}nohup ./frpc -c ./frpc.toml > frpc.log 2>&1 &exit
}fprsStop(){#根据端口号查询对应的pidpid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{ print $1 }');#杀掉对应的进程,如果pid不存在,则不执行if [  -n  "$pid"  ]thenkill  -9  $pid;echo "${port}端口对应的进程号${pid}被杀死"elseecho "${port}端口未启动"fi
}frpReStart(){fprsStopsleep 2sfprsStart}commport(){#根据端口号查询对应的pidpid=$(netstat -nlp | grep :$port | awk '{print $7}' | awk -F"/" '{ print $1 }');#杀掉对应的进程,如果pid不存在,则不执行if [  -n  "$pid"  ]thenecho "${port}端口对应的进程号${pid}"elseecho "${port}端口未启动"fi
}sele(){commport
}helpTxt(){echo "-----------------------------"echo "      start     启动frps        "echo "      stop      关闭frps        "echo "      restart   重启frps        "# echo "      2      启动frpc        "# echo "      3      关闭frpc        "echo "      sele      端口运行情况        "# echo "      exit   退出        "echo "-----------------------------"
}case "$1" in"start")fprsStart;;"stop")fprsStop;;"restart")frpReStart;;"sele")sele;;    *)helpTxt;;
esac# while :
#     do  
#         #键盘录入数据
#         helpTxt
#         echo "请输入指令" 
#         read meath
#         case ${meath} in
#             "0") 
#             fprsStart exit
#             ;;
#             "1") 
#             fprsStop exit
#             ;;
#             "4") 
#             sele exit
#             ;;
#             "5") 
#             helpTxt exit
#             ;;
#             "exit") 
#             echo "程序结束!"
#             break
#             ;;
#             *) 
#             echo "你输入的是'${meath}'不在范围内" 
#             continue
#             ;;
#         esac
# done# #键盘录入数据
# read meath
# case "$meath" in
#     "0") 
#     fprsStart exit
#     ;;
#     "1") 
#     fprsStop exit
#     ;;
#     "4") 
#     sele exit
#     ;;
#     "5") 
#     helpTxt exit
#     ;;
#     *) helpTxt exit
#     ;;
# esac

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词