基于Alpine镜像,从GitHub源码编译安装Tinyproxy的Dockerfile,使用清华大学镜像源
Dockerfile:

FROM alpine:latest AS builder

# 设置清华大学镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

# 安装编译依赖
RUN apk update && \
    apk add --no-cache \
    build-base \
    automake \
    autoconf \
    git \
    asciidoc \
    openssl-dev

# 克隆Tinyproxy源码
RUN git clone https://github.com/tinyproxy/tinyproxy.git /tinyproxy

# 编译安装
WORKDIR /tinyproxy
RUN ./autogen.sh && \
    ./configure && \
    make && \
    make install

# 最终镜像
FROM alpine:latest

# 设置清华大学镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

# 安装运行时依赖
RUN apk update && \
    apk add --no-cache \
    libgcc \
    openssl

# 从builder阶段复制编译结果
COPY --from=builder /usr/local/ /usr/local/

# 创建非特权用户
RUN adduser -S -D -H -h /run/tinyproxy tinyproxy

# 设置环境变量
ENV PORT=8888

# 修改配置文件(将所有sed命令合并为一行)
RUN sed -i -e '/^Allow /s/^/#/' -e '/^Bind /s/^/#/' -e "s/^Port 8888/Port $PORT/" /usr/local/etc/tinyproxy/tinyproxy.conf
RUN chmod 777 /usr/local/etc/tinyproxy/tinyproxy.conf

# 设置工作目录和用户
WORKDIR /usr/local/etc/tinyproxy
USER tinyproxy

# 暴露代理端口
EXPOSE $PORT

# 前台运行(-d选项表示前台模式)
CMD ["tinyproxy", "-d"]

构建镜像并运行

docker build -t tinyproxy:1.11.2 .
docker run --restart=always -d -p 8888:8888 tinyproxy:1.11.2

配置路径:/usr/local/etc/tinyproxy/tinyproxy.conf
修改用户名和密码,取消注释
BasicAuth user password
取消注释,开启隐藏代理头
DisableViaHeader Yes

Google Chrome插件:
https://github.com/FelisCatus/SwitchyOmega/releases
https://github.com/zero-peak/ZeroOmega

PS:如果不能访问Google等网站,请参考以下issue
2025-02-17T14:46:46.png
2025-02-17T14:47:15.png
来源:
https://github.com/tinyproxy/tinyproxy/issues/162
https://alstonwilliams.github.io/%E5%85%B6%E5%AE%83/2019/02/17/%E6%90%AD%E5%BB%BAHTTP-HTTPS%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%9D%A5%E7%BF%BB%E5%A2%99/

最后修改:2025 年 02 月 17 日
如果觉得我的文章对你有用,请随意赞赏