![使用隧道加密](https://rvso.com/image/717737/%E4%BD%BF%E7%94%A8%E9%9A%A7%E9%81%93%E5%8A%A0%E5%AF%86.png)
我在 CentOS 伺服器上運行 OTRS,MySQL 資料庫也在 CentOS 遠端伺服器上運行。 OTRS 不支援與 MySQL 的加密連接,因此該連接未加密。我想使用 stunnel 來加密連接,但我無法配置它。 MySQL 使用預設連接埠 3306。
OTRS = 10.0.0.4 MySQL = 10.0.0.3
#Sample stunnel configuration on OTRS Server
#Provide the full path to your certificate-key pair file
cert = /etc/pki/tls/certs/stunnel.pem
#lock the process into a chroot jail
chroot = /var/run/stunnel
# and create the PID file in this jail
pid = /stunnel.pid
#change the UID and GID of the process for security reasons
setuid = nobody
setgid = nobody
#enable client mode
client = yes
socket = l:TCP_NODELAY=1
#socket = r:TCP:NODELAY=1
[mysqls]
accept = 0.0.0.0:3306
connect = 10.0.0.3:3307
以及資料庫伺服器上的設定檔:
#Sample configuration file for MySQL
#Provide the full path to your certificate-key pair file
cert = /etc/pki/tls/certs/stunnel.pem
#Allow only TLS, thus avoiding SSL
sslVersion = TLSv1
#lock the process into a chroot jail
chroot = /var/run/stunnel
#change the UID and GID of the process for security reasons
setuid = nobody
setgid = nobody
pid = /stunnel.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
#Configure our secured MySQL Server
[mysqls]
accept = 3307
connect = 3306
我猜 OTRS 伺服器上的 stunnel 設定檔中的部分是錯誤的。有任何想法嗎?
接受= 0.0.0.0:3306
答案1
好吧,我明白了。
我已將 Config.pm 檔案中的資料庫主機值從資料庫伺服器的真實 IPv4 位址變更為 127.0.0.1:
然後,我在 OTRS 盒子上配置 stunnel.conf 以偵聽 127.0.0.1:3306(OTRS 預設情況下連接到標準 MySQL 連接埠)並連接到資料庫主機的真實 IPv$ 位址,但在連接埠 3307 上:
在資料庫伺服器上,stunnel.conf 如下所示:
在資料庫伺服器上執行 tcpdump 並在 Wireshark 中分析 .pcap,它顯示連接已加密且 OTRS 仍然有效:
我還不知道 stunnel.conf 檔案是否建置良好,但例如我讀到 chroot 不應該使用更長時間,但會更深入地研究它。