我使用 Dokploy 部署了一个带有 docker compose 和 traefik(反向代理)的 ghost 博客实例。我在从浏览器访问 ghost 博客部署时遇到问题:出现 Bad Gateway 错误。如果我使用2368
ghost 部署的默认端口,则一切正常,但如果我使用端口映射3204:2368
在其他端口上访问它,则会收到 Bad Gateway 错误。
docker-compose.yml:
name: ghost-live-1
services:
ghost:
image: ghost:5-alpine
container_name: ghost_serv_live_k
restart: always
environment:
database__client: mysql
database__connection__host: ghst_db
database__connection__user: ghost
database__connection__password: ghost
database__connection__database: ghost
url: https://blog.mydomain.com
NODE_ENV: production
ports:
- '3204:2368'
labels:
- traefik.docker.network=dokploy-network
- traefik.enable=true
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-web.rule=Host(`blog.mydomain.com`)
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-web.entrypoints=web
- traefik.http.services.ghostlive-ghost-2e1bbd-50-web.loadbalancer.server.port=3204
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-web.service=ghostlive-ghost-2e1bbd-50-web
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-web.middlewares=redirect-to-https@file
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-websecure.rule=Host(`blog.mydomain.com`)
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-websecure.entrypoints=websecure
- traefik.http.services.ghostlive-ghost-2e1bbd-50-websecure.loadbalancer.server.port=3204
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-websecure.service=ghostlive-ghost-2e1bbd-50-websecure
- traefik.http.routers.ghostlive-ghost-2e1bbd-50-websecure.tls.certresolver=letsencrypt
volumes:
- ghost_serv:/var/lib/ghost/content
depends_on:
ghst_db:
condition: service_healthy
networks:
- dokploy-network
ghst_db:
image: mysql:9
container_name: ghost_db_live_k
restart: always
environment:
MYSQL_ROOT_PASSWORD=example
MYSQL_DATABASE=ghost
MYSQL_USER=ghost
MYSQL_PASSWORD=ghost
networks:
- dokploy-network
volumes:
- ghost_db:/var/lib/mysql
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-h'
- 127.0.0.1
interval: 10s
timeout: 5s
retries: 3
start_period: 60s
volumes:
ghost_serv:
driver: local
ghost_db:
driver: local
networks:
dokploy-network:
external: true
我是否缺少一些关键配置,以致于 ghost 容器无法被 traefik 反向代理访问?