使用Traefik代理部分服务时出现502 Bad Gateway错误排查
Traefik代理Pi-hole出现502 Bad Gateway问题排查求助
我是Docker和Traefik新手,正在配置Traefik代理多个服务,部分服务可正常访问,但访问Pi-hole时出现502 Bad Gateway错误。通过https://myhost/nginx能正常获取Nginx测试页面,但访问https://myhost/pihole时加载5分钟后返回502错误。目前证书存在默认证书而非生产证书的问题,但推测与此无关。已通过Portainer确认Traefik、Pi-hole和Nginx处于同一网络“all_default”。以下是我的docker-compose.yml和Traefik配置文件,请求协助排查问题原因。
docker-compose.yml配置
version: '3' services: portainer: image: portainer/portainer:latest ports: - "9000:9000" command: - --admin-password=<somePwd> networks: - local volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer-data:/data traefik: image: "traefik:v2.5" container_name: "traefik" ports: - "80:80" - "443:443" # (Optional) Expose Dashboard - "8080:8080" # Don't do this in production! volumes: - ./etc-traefik:/etc/traefik - /var/run/docker.sock:/var/run/docker.sock:ro - traefik-ssl-certs:/ssl-certs command: - --log.level=DEBUG nginx: image: nginx:latest labels: - "traefik.enable=true" - "traefik.http.routers.nginx.middlewares=nginx" - "traefik.http.middlewares.nginx.stripprefix.prefixes=/nginx" - "traefik.http.routers.nginx.entrypoints=web,websecure" - "traefik.http.routers.nginx.rule=Path(`/nginx`)" - "traefik.http.routers.nginx.tls=true" - "traefik.http.routers.nginx.tls.certresolver=production" pihole: container_name: pihole image: pihole/pihole:latest # For DHCP it is recommended to remove these ports and instead add: network_mode: "host" ports: - "53:53/tcp" - "53:53/udp" environment: TZ: 'Europe/Warsaw' DNS1: 127.0.0.1 DNS2: 9.9.9.9 volumes: - './etc-pihole:/etc/pihole' - './etc-dnsmasq.d:/etc/dnsmasq.d' - '/etc/resolv.conf:/etc/resolv.conf' restart: unless-stopped command: - --log.level=DEBUG labels: - "traefik.enable=true" - "traefik.http.routers.pihole.middlewares=pihole" - "traefik.http.middlewares.pihole.stripprefix.prefixes=/pihole" - "traefik.http.routers.pihole.entrypoints=web,websecure" - "traefik.http.routers.pihole.rule=Path(`/pihole`)" - "traefik.http.routers.pihole.tls=true" - "traefik.http.routers.pihole.tls.certresolver=production" - "traefik.port=80" networks: local: driver: bridge volumes: portainer-data: traefik-ssl-certs: driver: local
Traefik配置文件
global: checkNewVersion: true sendAnonymousUsage: false # true by default # (Optional) Enable API and Dashboard # --- api: dashboard: true # true by default insecure: true # Don't do this in production! # Entry Points configuration # --- entryPoints: web: address: :80 # (Optional) Redirect to HTTPS # --- http: redirections: entryPoint: to: websecure scheme: https websecure: address: :443 # Configure your CertificateResolver here... # --- certificatesResolvers: staging: acme: email: email@email storage: /etc/traefik/certs/acme.json caServer: "https://acme-staging-v02.api.letsencrypt.org/directory" httpChallenge: entryPoint: web production: acme: email: email@email storage: /etc/traefik/certs/acme.json caServer: "https://acme-v02.api.letsencrypt.org/directory" httpChallenge: entryPoint: web providers: docker: exposedByDefault: false # Default is true file: # watch for dynamic configuration changes directory: /etc/traefik watch: true
Portainer网络截图

内容的提问来源于stack exchange,提问作者skarembel
相关产品推荐
相关产品推荐

