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
参考链接:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库