sudo apt install stunnel
三、配置node
sudo vim /etc/default/stunnel4
將「ENABLE」的值改爲「1」vim
四、建立證書bash
sudo mkdir /etc/stunnel/tls cd /etc/stunnel/tls sudo openssl genrsa -out key.pem 2048 #建立一個2048位的祕鑰 sudo openssl req -new -x509 -key key2.pem -out cert2.pem -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=域名或主機名" sudo chmod 640 key.pem cert.pem private.pem
上述操做是在建立自有證書,若你有從CA機構買來的證書可替換上述操做網絡
五、編寫stunnel的配置文件加密
sudo vim /etc/stunnel/stunnel.conf pid = /var/run/stunnel4/stunnel.pid output = /var/log/stunnel4/stunnel.log #日誌位置 [node_exporter] accept = 9101 #外界訪問的端口,IP默認是本機 connect = 127.0.0.1:9100 #須要加密的URL,當外界訪問本機的9101端口時會訪問到9100,而且9101端口出去的是ssl加密過的數據 cert = /etc/stunnel/tls/cert.pem key = /etc/stunnel/tls/key.pem
六、啓動stunnelrest
sudo systemctl restart stunnel4.service sudo systemctl enable stunnel4.service
sudo systemctl status stunnel4.service #檢查stunnel運行是否成功
七、驗證日誌
在本機打開wireshark,監聽使用的網卡,同時打開兩個網頁,一個訪問9100(9100)端口,另外一個訪問9101(https)端口。blog
查看http協議的抓包信息ssl
查看https的包openssl