stunnel server

1.6. 安装 Stunnel

从存储库安装 Stunnel 版本 4:

apt install stunnel -y

1.7. 生成 Stunnel 服务器私钥和证书

依次发出以下命令,为 Stunnel 服务器生成私钥和证书:

cd /etc/stunnel

openssl genrsa -out key.pem 2048

openssl req -new -x509 -key key.pem -out cert.pem -days 3650

您可以根据需要接受或覆盖证书的标识符:

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

插入这些内容。Stunnel 将侦听端口443并在端口内部将流量传递给 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。启用自动启动

编辑默认文件:

vi /etc/default/stunnel4

插入新行:

ENABLED=1

保存文件。

1.10。启动隧道

立即启动 Stunnel:

stunnel

检查它是否处于活动状态并正在收听:

tail /var/log/stunnel4/stunnel.log

您应该看到一条消息,Configuration successful。再做一些检查:

ps -aux | grep stunnel

ss -tulpn | grep 443

服务器工作完成,所以退出:

exit

你可能感兴趣的:(stunnel server)