本站支持搜索的镜像仓库:Docker Hub、gcr.io、ghcr.io、quay.io、k8s.gcr.io、registry.gcr.io、elastic.co、mcr.microsoft.com

该Docker镜像旨在替换HTTP服务器或K8S集群的标准错误页面,提供更具原创性和吸引力的替代方案。包含以下核心组件:Go语言编写的错误页面生成器、多种设计风格的单页错误模板(主题)、轻量级HTTP服务器(独立二进制文件或Docker镜像形式提供)以及预生成的错误页面资源。
Content-Type或X-Format请求头返回对应格式响应(支持json、xml、plaintext)/healthz,支持服务状态监控| 镜像仓库 | 镜像地址 |
|---|---|
| GitHub Container Registry (GHCR) | ghcr.io/tarampampam/error-pages |
| Docker Hub(镜像) | tarampampam/error-pages |
[!重要] 强烈不建议使用
latest标签,因为主版本升级可能包含不兼容变更。请使用X.Y.Z格式的具体版本标签。
从GitHub Releases页面下载对应操作系统/架构的最新预编译二进制文件。
可直接下载已渲染的错误页面压缩包:
以下模板已内置,无需额外配置即可使用:
| 模板名称 | 说明 |
|---|---|
app-down | 应用下线风格,简洁明了 |
cats | 猫咪图片风格(唯一依赖外部资源的模板,需联网加载图片) |
connection | 网络连接风格,带有连接状态可视化元素 |
ghost | 幽灵主题,深色背景与动态效果 |
hacker-terminal | 黑客终端风格,模拟命令行界面 |
l7 | L7风格,现代简约设计 |
lost-in-space | 太空迷失风格,科幻主题 |
noise | 噪点风格,复古颗粒感设计 |
orient | 东方风格,融合传统元素 |
shuffle | 随机风格,动态变化视觉效果 |
win98 | Windows 98风格,复古操作系统界面 |
[!注意]
cats模板会从外部服务器加载实际猫咪图片,其他模板均为自包含设计,不依赖外部资源。
./error-pages serve
docker run --rm -p '8080:8080/tcp' tarampampam/error-pages serve
服务器默认监听0.0.0.0:8080,可通过[***]{状态码}.html访问错误页面(如[***])。
通过X-Code HTTP头指定错误状态码,使用静态URL访问:
curl -H 'X-Code: 500' [***]
--template-name或环境变量TEMPLATE_NAME切换模板(如TEMPLATE_NAME=l7)--show-details或环境变量SHOW_DETAILS=true启用详细错误信息(含上游代理信息)--rotation-mode或环境变量TEMPLATES_ROTATION_MODE启用模板自动切换(支持random-on-startup/random-on-each-request/random-hourly/random-daily)my-super-theme.html:<!DOCTYPE html> <html lang="zh-CN"> <head> <title>{{ code }} - 自定义错误页面</title> </head> <body> <h1>错误 {{ code }}: {{ message }}</h1> <p>{{ description }}</p> </body> </html>
docker run --rm \ -v "$(pwd)/my-super-theme.html:/opt/my-template.html:ro" \ -p '8080:8080/tcp' \ ghcr.io/tarampampam/error-pages:3 serve \ --add-template /opt/my-template.html \ --template-name my-template
curl -H "Accept: text/html" [***]
使用自定义模板生成静态错误页面文件:
# 创建输出目录 mkdir -p /path/to/output # 生成错误页面 ./error-pages build \ --add-template /path/to/your/my-template.html \ --target-dir /path/to/output
生成的文件结构示例:
/path/to/output/ └── my-template ├── 400.html ├── 401.html ├── 403.html ├── 404.html ├── ...(其他状态码文件)
nginx.conf:server { listen 80; server_name localhost; # 配置错误页面映射 error_page 401 /_error-pages/401.html; error_page 403 /_error-pages/403.html; error_page 404 /_error-pages/404.html; error_page 500 /_error-pages/500.html; error_page 502 /_error-pages/502.html; error_page 503 /_error-pages/503.html; # 内部错误页面路径配置 location ^~ /_error-pages/ { internal; root /usr/share/nginx/errorpages; } # 主站点配置 location / { root /usr/share/nginx/html; index index.html index.htm; } }
FROM docker.io/library/nginx:1.27-alpine # 覆盖默认Nginx配置 COPY --chown=nginx ./nginx.conf /etc/nginx/conf.d/default.conf # 从error-pages镜像复制预生成的错误页面(将ghost替换为其他模板名称) COPY --chown=nginx \ --from=ghcr.io/tarampampam/error-pages:3 \ /opt/html/ghost /usr/share/nginx/errorpages/_error-pages
# 构建镜像 docker build --tag your-nginx:local -f ./Dockerfile . # 启动镜像 docker run --rm -p '8081:80/tcp' your-nginx:local # 测试错误页面(新终端) curl [***]
创建compose.yml文件:
services: traefik: image: docker.io/library/traefik:v3.1 command: - --api.dashboard=true - --api.insecure=true - --providers.docker=true - --providers.docker.exposedbydefault=false - --entrypoints.web.address=:80 ports: - "80:80/tcp" volumes: - /var/run/docker.sock:/var/run/docker.sock:ro labels: traefik.enable: true traefik.http.routers.traefik.rule: Host(`traefik.localtes***`) traefik.http.routers.traefik.service: api@internal traefik.http.routers.traefik.entrypoints: web traefik.http.routers.traefik.middlewares: error-pages-middleware depends_on: error-pages: {condition: service_healthy} error-pages: image: ghcr.io/tarampampam/error-pages:3 environment: TEMPLATE_NAME: l7 # 设置模板名称 labels: traefik.enable: true traefik.http.routers.error-pages-router.rule: HostRegexp(`.+`) traefik.http.routers.error-pages-router.priority: 10 traefik.http.routers.error-pages-router.entrypoints: web traefik.http.routers.error-pages-router.middlewares: error-pages-middleware # 错误中间件配置 traefik.http.middlewares.error-pages-middleware.errors.status: 400-599 traefik.http.middlewares.error-pages-middleware.errors.service: error-pages-service traefik.http.middlewares.error-pages-middleware.errors.query: /{status}.html traefik.http.services.error-pages-service.load***.server.port: 8080 # 测试服务(可选) nginx-or-any-another-service: image: docker.io/library/nginx:1.27-alpine labels: traefik.enable: true traefik.http.routers.test-service.rule: Host(`test.localtes***`) traefik.http.routers.test-service.entrypoints: web traefik.http.routers.test-service.middlewares: error-pages-middleware
启动服务:
docker compose up
访问测试:
[***][***]通过Helm配置Ingress Nginx,添加以下参数至values.yaml:
controller: config: custom-http-errors: >- 401,403,404,500,501,502,503 # 需处理的错误状态码 defaultBackend: enabled: true image: repository: ghcr.io/tarampampam/error-pages tag: '3' # 指定具体版本,不建议使用latest extraEnvs: - name: TEMPLATE_NAME # 可选:设置模板 value: l7 - name: SHOW_DETAILS # 可选:启用详细错误信息 value: 'true'
通过Helm部署错误页面服务及Traefik中间件,主要包含以下资源(示例模板):
apiVersion: v1 kind: Namespace metadata: name: error-pages
apiVersion: apps/v1 kind: Deployment metadata: name: error-pages namespace: error-pages labels: app: error-pages spec: replicas: 1 selector: matchLabels: app: error-pages template: metadata: labels: app: error-pages spec: automountServiceAccountToken: false containers: - name: error-pages image: ghcr.io/tarampampam/error-pages:3 env: - name: TEMPLATE_NAME value: shuffle # 设置模板 securityContext: runAsNonRoot: true runAsUser: *** runAsGroup: *** readOnlyRootFilesystem: true ports: - name: http containerPort: 8080 livenessProbe: httpGet: path: /healthz port: http readinessProbe: httpGet: path: /healthz port: http resources: limits: memory: 64Mi cpu: 200m requests: memory: 16Mi cpu: 20m
apiVersion: v1 kind: Service metadata: name: error-pages-service namespace: error-pages spec: type: ClusterIP selector: app: error-pages ports: - name: http port: 8080 targetPort: 8080
apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: name: error-pages namespace: error-pages spec: errors: status: ["401", "403", "404", "500-599"] service: name: error-pages-service port: 8080 query: "/{status}.html"
应用上述资源后,在Traefik IngressRoute中引用中间件:
apiVersion: traefik.io/v1alpha1 kind: IngressRoute metadata: name: example-app namespace: example spec: entryPoints: - websecure routes: - match: Host(`app.example.com`) kind: Rule services: - name: example-service port: 80 middlewares: - name: error-pages namespace: error-pages # 跨命名空间引用需Traefik开启allowCrossNamespace
注:Traefik需配置
--providers.kubernetescrd.allowCrossNamespace=true以支持跨命名空间中间件引用。
免费版仅支持 Docker Hub 加速,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
免费版仅支持 docker.io;专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录方式配置轩辕镜像加速服务,包含7个详细步骤
在 Linux 系统上配置轩辕镜像源,支持主流发行版
在 Docker Desktop 中配置轩辕镜像加速,适用于桌面系统
在 Docker Compose 中使用轩辕镜像加速,支持容器编排
在 k8s 中配置 containerd 使用轩辕镜像加速
在宝塔面板中配置轩辕镜像加速,提升服务器管理效率
在 Synology 群晖NAS系统中配置轩辕镜像加速
在飞牛fnOS系统中配置轩辕镜像加速
在极空间NAS中配置轩辕镜像加速
在爱快ikuai系统中配置轩辕镜像加速
在绿联NAS系统中配置轩辕镜像加速
在威联通NAS系统中配置轩辕镜像加速
在 Podman 中配置轩辕镜像加速,支持多系统
配置轩辕镜像加速9大主流镜像仓库,包含详细配置步骤
无需登录即可使用轩辕镜像加速服务,更加便捷高效
需要其他帮助?请查看我们的 常见问题 或 官方QQ群: 13763429