使用frp0.61.0透传局域网的https服务到自有域名

**本文成因:**我之前已经写过多个frp+https的文章,但因为frp版本升级后,更换了配置文件,其格式和之前差别比较明显,其次,之前的教程也过于繁杂,因此做出更新和改进。主要是展示各部分的配置文件,不在对配置原理进行介绍。 对原理感兴趣的,可以参看我之前的文章。

使用frp结合nginx实现对https的反向代理支持_frp+nginx反向代理-CSDN博客

利用frps搭建本地自签名https服务的透传_frp ssl-CSDN博客

一、frps 服务端frps.toml配置

该服务器自身运行着一个web,所以,不占用其80端口 ; 域名为 www.test-service.com

复制代码
cat /etc/frp/frps.toml

bindPort = 7000
vhostHTTPSPort = 443
vhostHTTPPort = 8080

二、frps 服务端 nginx配置

复制代码
cat /etc/nginx/conf.d/test1.conf

server {
        listen      80 ;
        listen      [::]:80 ;
        server_name test1.test-service.com;
        rewrite ^/(.*)$ https://test1.test-service.com:443/$1 permanent;
        #               location / {
        #  proxy_pass http://127.0.0.1:443;
        # }
    }

**注:**仅需要将域名部分替换掉即可,也就是 test1.test-service.com 替换成你自己的

三、frpc 客户端 nginx配置

复制代码
server {
        listen 55580 default_server;       ## 不影响
        listen [::]:55590 default_server;  ## 不影响

        # SSL configuration
        #
         listen 32443 ssl default_server;        ##  指定SSL服务的端口
         listen [::]:32443 ssl default_server;   ##  指定SSL服务的端口

        #ssl证书的pem文件路径
         ssl_certificate  /home/SSL/web.crt;

        #ssl证书的key文件路径
         ssl_certificate_key /home/SSL/web.key;
         
        #web服务的根目录
        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
       }

**注:**这里最好改一下ssl listen 的端口号,如果客户端上有多个web服务,则每个web服务要使用不同的配置文件名称和差异化的端口号

四、frpc 客户端frpc.toml配置

复制代码
cat /etc/frp/frpc.toml

serverAddr = "www.test-service.com"
serverPort = 7000

[[proxies]]
name = "ssh-t1"
type = "tcp"
localIP = "127.0.0.1"
localPort = 32222
remotePort = 32222

[[proxies]]
name = "web-1"
type = "https"
localPort = 32443
customDomains = ["test1.test-service.com"]

五、重启相关服务,测试是否成功

分别重启 frps 服务端的 frps 和nginx服务,以及 客户端的frpc服务和nginx服务

复制代码
## 在frps 服务器上

systemctl restart frps
systemctl restart nginx

## 在frpc 服务器上(局域网中)
systemctl restart frpc
systemctl restart nginx

浏览器中打开 https://test1.test-service.com 测试是否成功

相关推荐
北城以北1231 小时前
生成树协议STP详解
网络协议
杰瑞学AI2 小时前
我的全栈学习之旅:FastAPI (持续更新!!!)
后端·python·websocket·学习·http·restful·fastapi
ErizJ7 小时前
WebSocket | 一点简单了解
网络·websocket·网络协议
游戏开发爱好者87 小时前
BShare HTTPS 集成与排查实战,从 SDK 接入到 iOS 真机调试(bshare https、签名、回调、抓包)
android·ios·小程序·https·uni-app·iphone·webview
2501_9151063210 小时前
苹果软件加固与 iOS App 混淆完整指南,IPA 文件加密、无源码混淆与代码保护实战
android·ios·小程序·https·uni-app·iphone·webview
2501_9160137413 小时前
iOS 推送开发完整指南,APNs 配置、证书申请、远程推送实现与上架调试经验分享
android·ios·小程序·https·uni-app·iphone·webview
2501_9159090617 小时前
HTML5 与 HTTPS,页面能力、必要性、常见问题与实战排查
前端·ios·小程序·https·uni-app·iphone·html5
CiLerLinux21 小时前
第五十二章 ESP32S3 UDP 实验
网络·单片机·嵌入式硬件·网络协议·udp
切糕师学AI21 小时前
P2P技术
网络·网络协议·p2p
2501_916013741 天前
iOS 上架 App 全流程实战,应用打包、ipa 上传、App Store 审核与工具组合最佳实践
android·ios·小程序·https·uni-app·iphone·webview