1. 程式人生 > 實用技巧 >基於frp的內網穿透例項4-為本地的web服務實現HTTPS訪問

基於frp的內網穿透例項4-為本地的web服務實現HTTPS訪問

原文地址:https://wuter.cn/1932.html/

一、想要實現的功能

目前已經實現將本地的web服務暴露到公網,現想要實現https訪問。(前提:已經有相應的證書檔案,如果沒有就去申請Let's Encrypt Authority x3這種免費證書)

●如何利用frpc實現將本地web服務對映到公網參考文章:基於frp的內網穿透例項2-通過自定義域名訪問部署於內網的 web 服務

二、服務端配置

1、修改frps.ini檔案

[common] bind_port = 7000 vhost_https_port = xxx #這裡的xxx即在外網訪問時加在域名後面的埠,比如www.baidu.com:80

2、過載frps.service服務

systemctl restart frps

如果想要確認是否過載成功,輸入以下程式碼檢驗:

systemctl status frps -l

●如何將frpc作為服務項自動啟動參考上一篇文章:frp後臺自動啟動的方法

三、客戶端配置

1、修改frpc.ini檔案

[common] server_addr = dns.ihuster.cn #伺服器地址或域名 server_port = 7000 [ssh-web-8003to80]#這裡先把http暴露到公網8003埠,配合反向代理實現80埠訪問 type = tcp
local_ip = 127.0.0.1 local_port = 80 remote_port = 8003 [ssh-htts2http-demo] type = https custom_domains = frp.qimumu.top #這是你的域名 plugin = https2http #載入https2http外掛 plugin_local_addr = 127.0.0.1:80 #這裡的80埠是你內網http實際的監聽埠 # HTTPS 證書相關的配置 plugin_crt_path = ./ssl.crt #證書命名為ssl.crt plugin_key_path = ./ssl.key #私鑰命名為ssl.crt ,這裡證書和私鑰都放到frp目錄下
plugin_host_header_rewrite = 127.0.0.1 plugin_header_X-From-Where = frp

2、過載frpc.service服務

systemctl restart frpc

四、測試

1、http訪問

2、https訪問

成功!