Docker、TinyProxy、Stunnel、Let's Encrypt
最近有cookie共享的需求,需要用到袋里服务器,选用TinyProxy,简单易配置,缺点,支持的协议较少,只有htp和https,不支持Socks5。而且传输回客户端用的是http协议,袋里某些网站会被**影响。
最终方案:TinyProxy + Stunnel + Let's Encrypt 证书
TinyProxy只需要对localhost开放它的端口,Stunnel则对外开放端口
Docker安装TinyProxy
docker run -d --name='tinyproxy' -p 8848:8888 dannydirect/tinyproxy:latest ANY
容器内/etc/tinyproxy/tinyproxy.conf文件内容
User tinyproxy Group tinyproxy Port 8888 Timeout 600 DefaultErrorFile "/usr/share/tinyproxy/default.html" StatFile "/usr/share/tinyproxy/stats.html" LogFile "/var/log/tinyproxy/tinyproxy.log" LogLevel Info MaxClients 100 MinSpareServers 5 MaxSpareServers 20 StartServers 10 MaxRequestsPerChild 0 ViaProxyName "tinyproxy" ConnectPort 443 ConnectPort 563
将宝塔生成的Let Encript证书生成软链接放到stunnel目录下
ln -s /www/server/panel/vhost/cert/mywebsite.com/fullchain.pem /opt/stunnel/fullchain.pem ln -s /www/server/panel/vhost/cert/mywebsite.com/privkey.pem /opt/stunnel/privkey.pem
yum安装Stunnel
yum install stunnel
/opt/stunnel/stunnel.conf文件内容
; 设置工作目录,没有目录需要先创建 chroot = /var/run/stunnel/ ; 设置stunnel的pid文件路径(在chroot下) pid = /stunnel.pid ; 设置stunnel工作的用户(组) ; 设置工作目录,没有目录需要先创建 ;chroot = /var/run/stunnel/ chroot = /opt/stunnel/work ; 设置stunnel的pid文件路径(在chroot下) pid = /stunnel.pid ; 设置stunnel工作的用户(组) setuid = root setgid = root ; 开启日志等级:emerg (0), alert (1), crit (2), err (3), warning (4), notice (5), info (6), or debug (7) ; 默认为5 debug = 7 ; 日志文件路径(我的server的版本有个bug,这个文件也被放在chroot路径下了,client的版本则 ;是独立的=。=#) output = /stunnel.log ; 证书文件,直接使用Let's Encript证书(server端必须设置这两项) cert = /opt/stunnel/fullchain.pem ; 私钥文件 key = /opt/stunnel/privkey.pem ; 设置stunnel服务,可以设置多个服务,监听同的端口,并发给不同的server。 ; 自定义服务名squid-proxy [TinyProxy-proxy] ; 服务监听的端口,client要连接这个端口与server通信 accept = 8849 ; 服务要连接的端口,连接到squid的8848端口,将数据发给TinyProxy connect = 172.17.0.1:8848 client = no sslVersion = all options = NO_SSLv2
启动Stunnel
cd /opt/stunnel stunnel /opt/stunnel/stunnel.conf
参考链接:
浙公网安备 33010602011771号