frp使用反向代理实现https协议
注意服務(wù)端和客戶端的版本是需要一致的
如只有一端不知道版本可以進(jìn)入目錄通過./frps -v或者./frpc -v查看版本號(hào)
對(duì)于沒有使用過frp的,可以看我之前寫 樹莓派實(shí)現(xiàn)內(nèi)網(wǎng)穿透的那篇博客
1、下載SSL證書
這里我使用阿里云的服務(wù)器,所以就在阿里云上申請(qǐng)一個(gè)免費(fèi)的證書。具體操作過程就不多解釋了。。。
注意下載要是nginx的證書
2、使用frp進(jìn)行https代理
此方式需要注意的是這里的證書是放在客戶端下的
進(jìn)入frps.ini,輸入命令
vim frps.ini編輯
[common] bind_addr = 0.0.0.0 bind_port = 7000 #服務(wù)器開放端口,用于客戶端與服務(wù)器通信 vhost_http_port = 80 #http虛擬端口,http請(qǐng)求 vhost_https_port = 443 #hhtps虛擬端口 token = XXXXX #驗(yàn)證信息,客戶端需一致dashboard_user = admin # 管理頁面用戶名 dashboard_pwd = admin@123 # 管理員密碼 dashboard_port = 81 # 管理后臺(tái)的端口然后運(yùn)行
nohup ./frps -c ./frps.ini &> frps.log &首先上傳證書
保存,運(yùn)行
nohup ./frpc -c ./frpc.ini &> frpc.log &3、使用frp和Nginx進(jìn)行https代理
這里說明一下原理:當(dāng)你訪問頁面的時(shí)候,通過Nginx監(jiān)聽80端口(http)和443端口(https),所有http請(qǐng)求將重定向https請(qǐng)求。接著Nginx將請(qǐng)求轉(zhuǎn)發(fā)給frp的http虛擬端口,然后最后將請(qǐng)求發(fā)給frp客戶端。
那么我們首先設(shè)置Nginx的配置文件,要是對(duì)Nginx不大懂的,可以看我寫的另外一篇(雖然寫的也很簡(jiǎn)單)。
上傳證書
關(guān)閉Nginx服務(wù)器
systemctl stop nginx.service編輯配置文件
server {listen 443 ssl;ssl_certificate /etc/nginx/5414927_jonion.top.pem; # 證書存放位置ssl_certificate_key /etc/nginx/5414927_jonion.top.key; # 證書存放位置server_name jonion.top; #自己的網(wǎng)站域名# Load configuration files for the default server block.include /etc/nginx/default.d/*.conf;location / {proxy_pass http://127.0.0.1:6666; #frp設(shè)置的端口 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $http_host;proxy_set_header X-NginX-Proxy true;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_max_temp_file_size 0;proxy_redirect off;proxy_read_timeout 240s;}error_page 404 /404.html;location = /404.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {root /usr/share/nginx/html;}}server {listen 80; #監(jiān)聽80端口server_name jonion.top; #你自己的網(wǎng)站return 301 https://$server_name$request_uri; }運(yùn)行Nginx
systemctl restart nginx.service運(yùn)行
nohup ./frps -c ./frps.ini &> frps.log &運(yùn)行
nohup ./frpc -c ./frpc.ini &> frpc.log &然后就可以訪問啦,歡迎訪問我的博客野生程序員
總結(jié)
以上是生活随笔為你收集整理的frp使用反向代理实现https协议的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于物联网的自动灌溉系统的设计与实现
- 下一篇: 应用于3D图形制作环境的_JITStac