diff --git a/Other/nginx-tengine-3.1.0/Dockerfile b/Other/nginx-tengine-3.1.0/Dockerfile index b9d88f7..19a3312 100644 --- a/Other/nginx-tengine-3.1.0/Dockerfile +++ b/Other/nginx-tengine-3.1.0/Dockerfile @@ -41,9 +41,11 @@ RUN yum install \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-pcre-jit; \ - make && make install; \ + make; \ + make install; \ mkdir -p ${NGINX_HOME}/conf/ssl ${NGINX_HOME}/conf/conf.d; \ - nginx -V; \ + ls -l ${NGINX_HOME}/sbin; \ + ${NGINX_HOME}/sbin/nginx -V; \ rm -rf /home/admin/tengine-${TENGINE_VERSION} /home/admin/tengine-${TENGINE_VERSION}.tar.gz # tengine 默认以 nobody 用户运行 worker 进程,root 启动后自动降权,可直接监听 80/443 diff --git a/Other/nginx-tengine-3.1.0/nginx.conf b/Other/nginx-tengine-3.1.0/nginx.conf index c34210e..39e88a6 100644 --- a/Other/nginx-tengine-3.1.0/nginx.conf +++ b/Other/nginx-tengine-3.1.0/nginx.conf @@ -1,22 +1,63 @@ user root; -worker_processes auto; +# 按 CPU 核数设置,超过 8 个收益很小;需要时可直接改成具体数字,如 4 +worker_processes auto; +# 每个 worker 打开的文件描述符上限,为高并发场景预留 +worker_rlimit_nofile 65535; + +# 错误日志级别 warn,避免大量冗余 info 日志;容器内输出到 stderr 方便收集 +error_log stderr warn; events { - worker_connections 1024; + # 高并发场景用 epoll;worker_connections 与 worker_processes 相乘即最大并发连接数 + use epoll; + worker_connections 10240; + multi_accept on; } http { include mime.types; default_type application/octet-stream; + log_format main '"$http_x_forwarded_for" $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"'; - #access_log logs/access.log main; - sendfile on; + + # 容器环境下日志输出到 stdout/stderr,交给 docker 日志驱动统一处理 + access_log /dev/stdout main; + + # 只为低版本浏览器不支持的格式做 gzip,现代浏览器直接用 gzip_static 提供的 .gz 文件 + gzip on; + gzip_vary on; + gzip_comp_level 5; + gzip_min_length 1k; + gzip_proxied any; + gzip_types text/plain text/css text/xml application/json application/javascript + application/rss+xml application/atom+xml image/svg+xml; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; keepalive_timeout 65; + # 客户端请求头/请求体超时,防止慢连接长期占用 worker + client_header_timeout 15s; + client_body_timeout 15s; + send_timeout 15s; + # 调优: 32的倍数 - proxy_headers_hash_max_size 51200; - proxy_headers_hash_bucket_size 6400; - client_max_body_size 1200m; + server_names_hash_max_size 1024; + server_names_hash_bucket_size 128; + proxy_headers_hash_max_size 51200; + proxy_headers_hash_bucket_size 6400; + + client_max_body_size 1200m; + # 大文件上传时先把请求体落到磁盘,避免占用内存 + client_body_buffer_size 128k; + + # 文件缓存,减少磁盘 stat 次数;大小可视容器内打开文件数调整 + open_file_cache max=10000 inactive=30s; + open_file_cache_valid 60s; + open_file_cache_min_uses 2; + open_file_cache_errors on; + include /usr/local/nginx/conf/conf.d/*.conf; -} \ No newline at end of file +} diff --git a/System/Dockerfile b/System/Dockerfile index b7826ef..db841f4 100644 --- a/System/Dockerfile +++ b/System/Dockerfile @@ -3,4 +3,5 @@ LABEL MAINTAINER="tianjun@odboy.cn" ENV TimeZone=Asia/Shanghai WORKDIR /home/admin -RUN yum update -y && yum clean all; \ No newline at end of file +# 升级会有很多问题,比如nginx编译失败等 +#RUN yum update -y && yum clean all; \ No newline at end of file diff --git a/System/VULNERABILITY_FIX.md b/System/VULNERABILITY_FIX.md deleted file mode 100644 index e7d4a90..0000000 --- a/System/VULNERABILITY_FIX.md +++ /dev/null @@ -1,147 +0,0 @@ -# 基础镜像漏洞修复流程 - -## 镜像信息 - -| 项目 | 值 | -|-------|---------------------------------------------------------------------------------------| -| 镜像名称 | `registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update20261111` | -| 基础系统 | Alibaba Cloud Linux 3 (Soaring Falcon) | -| 基础镜像 | `alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:220901.1` | -| 已安装包数 | 128 | -| 可更新包数 | 110 | - -## 漏洞扫描结果 - -### trivy 扫描 - -trivy 无法识别 alinux3 的 OS 类型,系统包漏洞未被扫描,仅检测到 Python 包漏洞: - -| 严重级别 | 数量 | -|----------|----| -| CRITICAL | 0 | -| HIGH | 3 | -| MEDIUM | 1 | -| LOW | 1 | - -**Python 包漏洞 (setuptools 39.2.0)**: - -- CVE-2022-40897 (HIGH) - ReDoS -- CVE-2024-6345 (HIGH) - 远程代码执行 -- CVE-2025-47273 (HIGH) - 路径遍历 -- CVE-2026-59890 (MEDIUM) - MANIFEST.in 绕过 -- GHSA-xmj3-9gf7-h52w (LOW) - Windows 路径逃逸 - -### yum check-update 结果 - -110 个系统包可更新,包括关键组件: - -- `bash`, `glibc`, `openssl-libs`, `curl`, `sudo` -- `coreutils`, `systemd-libs`, `krb5-libs` -- `gnutls`, `libarchive`, `pam` 等 - ---- - -## 修复步骤 - -### 方式一:容器内修复并 commit(推荐) - -```bash -# 1. 启动容器 -docker run -it --name fix-vuln \ - registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update20261111 \ - /bin/bash - -# 2. 在容器内执行全量升级 -yum update -y && yum clean all - -# 3. 验证升级结果 -yum check-update # 应返回空或仅显示刚更新的包 -rpm -qa | wc -l # 确认包数量 - -# 4. 退出容器(Ctrl+D 或 exit) - -# 5. 提交为新镜像 -docker commit fix-vuln registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update$(date +%Y%m%d) - -# 6. 推送新镜像 -docker push registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update$(date +%Y%m%d) - -# 7. 清理容器 -docker rm fix-vuln -``` - -### 方式二:修改 Dockerfile 重建 - -修改 `System/Dockerfile`,在现有 RUN 指令后追加升级命令: - -```dockerfile -FROM alibaba-cloud-linux-3-registry.cn-hangzhou.cr.aliyuncs.com/alinux3/alinux3:220901.1 -LABEL MAINTAINER="tianjun@odboy.cn" -ENV TimeZone=Asia/Shanghai -WORKDIR /home/admin - -RUN yum update -y && yum clean all; \ - rm -rf /usr/lib/python3.6 -``` - -> 说明:ALinux3 官方镜像的 repo 已使用 `mirrors.aliyun.com`,不需要再做 `mirrors.cloud.aliyuncs.com` 换源; -> 时区由 `ENV TimeZone` 控制,运行时通常会被容器引擎挂载的宿主机 `/etc/localtime` 覆盖, -> 因此子镜像也不再重复 `ln -snf ... /etc/localtime`。 - -然后执行构建: - -```bash -cd System/ -bash build.sh -``` - -### 方式三:仅修复特定 CVE - -如果只想修复特定漏洞,可指定包名: - -```bash -# 示例:仅升级 openssl 和 glibc -yum update -y openssl-libs glibc && yum clean all -``` - ---- - -## 修复后验证 - -```bash -# 重新扫描 -trivy image registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-fix<新日期> - -# 检查可更新包 -docker run --rm <新镜像> yum check-update -``` - ---- - -## 更新下游镜像 - -基础镜像更新后,需要更新所有下游镜像的 FROM 标签: - -```bash -# 查找所有引用当前基础镜像的 Dockerfile -grep -r "alinux3-fix" --include="Dockerfile" . -``` - -涉及目录: - -- `Base/Compile/` - 编译环境 -- `Base/Runtime/` - 运行环境 -- `Base/Composite/` - 编译与运行环境 -- 其他所有基于 System 构建的镜像 - ---- - -## 注意事项 - -1. **trivy 限制**:trivy 不支持 alinux3 系统包扫描,系统级漏洞需通过 `yum check-update` 检查 -2. **Python 包**:setuptools 是系统自带 Python 包,升级可能影响系统工具,建议保持现状或谨慎升级 -3. **镜像标签**:建议使用日期标签(如 `alinux3-update20261111`)便于追溯 -4. **构建缓存**:重建时可使用 `--no-cache` 确保使用最新包: - ```bash - docker build --no-cache -t <镜像名> . - ``` diff --git a/System/pip.conf b/System/pip.conf deleted file mode 100644 index 4591cae..0000000 --- a/System/pip.conf +++ /dev/null @@ -1,5 +0,0 @@ -[global] -index-url = https://mirrors.aliyun.com/pypi/simple - -[install] -trusted-host = mirrors.aliyun.com \ No newline at end of file