yum install firewalld -y
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --permanent --zone=public --add-interface=eth0
firewall-cmd --reload

yum install stunnel -y

cat > /etc/stunnel/stunnel.conf << EOF
cert = /etc/pki/tls/certs/stunnel.pem
; Allow only TLS, thus avoiding SSL
sslVersion = TLSv1
chroot = /var/run/stunnel
setuid = stunnel
setgid = stunnel
pid = /stunnel.pid
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1

[redis]
client = yes
accept = 127.0.0.0.1:6379
connect = 10.1.100.1:6379
TIMEOUTclose = 0
EOF

cat > /etc/systemd/system/stunnel.service << EOF
[Unit]
Description=SSL tunnel
After=syslog.target

[Service]
ExecStart=/usr/bin/stunnel /etc/stunnel/stunnel.conf
ExecStop=/bin/kill -9 
ExecStatus=pgrep stunnel
Type=forking

[Install]
WantedBy=multi-user.target
EOF

systemctl start stunnel
systemctl enable stunnel

