1.6. 安裝 Stunnel
從存儲(chǔ)庫安裝 Stunnel 版本 4:
apt install stunnel -y
1.7. 生成 Stunnel 服務(wù)器私鑰和證書
依次發(fā)出以下命令,為 Stunnel 服務(wù)器生成私鑰和證書:
cd /etc/stunnel
openssl genrsa -out key.pem 2048
openssl req -new -x509 -key key.pem -out cert.pem -days 3650
您可以根據(jù)需要接受或覆蓋證書的標(biāo)識符:
Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []: Email Address []:
1.8. 配置 Stunnel
編輯 Stunnel 配置文件:
vi /etc/stunnel/stunnel.conf
插入這些內(nèi)容。Stunnel 將偵聽端口443
并在端口內(nèi)部將流量傳遞給 OpenVPN 1194
:
pid = /var/run/stunnel4/stunnel.pid output = /var/log/stunnel4/stunnel.log setuid = stunnel4 setgid = stunnel4 [openvpn] cert=/etc/stunnel/cert.pem key=/etc/stunnel/key.pem accept = 0.0.0.0:443 connect = 127.0.0.1:1194
將文件寫入磁盤过吻。退出編輯器座韵。
1.9物延。啟用自動(dòng)啟動(dòng)
編輯默認(rèn)文件:
vi /etc/default/stunnel4
插入新行:
ENABLED=1
保存文件。
1.10。啟動(dòng)隧道
立即啟動(dòng) Stunnel:
stunnel
檢查它是否處于活動(dòng)狀態(tài)并正在收聽:
tail /var/log/stunnel4/stunnel.log
您應(yīng)該看到一條消息,Configuration successful
辑畦。再做一些檢查:
ps -aux | grep stunnel
ss -tulpn | grep 443
服務(wù)器工作完成,所以退出:
exit