1

升级到 Portainer v2 后,图标突然不再加载。我仍然可以访问 Portainer(由 Traefik 代理),但经过一些测试,我注意到,只会/被转发。如果给出了路径,Traefik 会抛出 404 错误。这是一个问题,因为 Portainer 从例如加载字体。/b15db15f746f29ffa02638cb455b8ec0.woff2.

Github 上有一个关于此的问题,但我真的不知道如何处理该信息:https ://github.com/porttainer/portainer/issues/3706

我的 Traefik 配置

version: "2"

# Manage domain access to services
services:
  traefik:
    container_name: traefik
    image: traefik
    command:
      - --api.dashboard=true
      - --certificatesresolvers.le.acme.email=${ACME_EMAIL}
      - --certificatesresolvers.le.acme.storage=acme.json
      # Enable/Disable staging by commenting/uncommenting the next line
      # - --certificatesresolvers.le.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
      - --certificatesresolvers.le.acme.dnschallenge=true
      - --certificatesresolvers.le.acme.dnschallenge.provider=cloudflare
      - --entrypoints.http.address=:80
      - --entrypoints.https.address=:443
      - --global.sendAnonymousUsage
      - --log.level=INFO
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --providers.docker.network=traefik_proxy
    restart: always
    networks:
      - traefik_proxy
    ports:
      - "80:80"
      - "443:443"
    dns:
      - 1.1.1.1
      - 1.0.0.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./acme.json:/acme.json
      # - ./acme-staging.json:/acme.json
    environment:
      CF_API_EMAIL: ${CLOUDFLARE_EMAIL}
      CF_API_KEY: ${CLOUDFLARE_API_KEY}
    labels:
      - traefik.enable=true

      - traefik.http.routers.traefik0.entrypoints=http
      - traefik.http.routers.traefik0.rule=Host(`${TRAEFIK_URL}`)
      - traefik.http.routers.traefik0.middlewares=to_https

      - traefik.http.routers.traefik.entrypoints=https
      - traefik.http.routers.traefik.rule=Host(`${TRAEFIK_URL}`)
      - traefik.http.routers.traefik.middlewares=traefik_auth
      - traefik.http.routers.traefik.tls=true
      - traefik.http.routers.traefik.tls.certresolver=le
      - traefik.http.routers.traefik.service=api@internal

      # Declaring the user list
      #
      # Note: all dollar signs in the hash need to be doubled for escaping.
      # To create user:password pair, it's possible to use this command:
      # echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g
      - traefik.http.middlewares.traefik_auth.basicauth.users=${TRAEFIK_USERS}

      # Standard middleware for other containers to use
      - traefik.http.middlewares.to_https.redirectscheme.scheme=https
      - traefik.http.middlewares.to_https_perm.redirectscheme.scheme=https
      - traefik.http.middlewares.to_https_perm.redirectscheme.permanent=true

networks:
  traefik_proxy:
    external: true

还有我的搬运工配置

version: "2"

# Manage docker containers
services:
  portainer:
    container_name: portainer
    image: portainer/portainer-ce
    restart: always
    networks:
      - traefik_proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/:/data/
    labels:
      - traefik.enable=true

      - traefik.http.services.portainer.loadbalancer.server.port=9000

      - traefik.http.routers.portainer0.entrypoints=http
      - traefik.http.routers.portainer0.rule=Host(`${PORTAINER_URL}`)
      - traefik.http.routers.portainer0.middlewares=to_https

      - traefik.http.routers.portainer.entrypoints=https
      - traefik.http.routers.portainer.rule=Host(`${PORTAINER_URL}`)
      - traefik.http.routers.portainer.tls=true
      - traefik.http.routers.portainer.tls.certresolver=le

networks:
  traefik_proxy:
    external: true

为了让 Traefik 能够转发路径以便 Portainer 可以加载图标,我需要进行哪些更改?

4

3 回答 3

0

我注意到还有一个高山版本的 Portainer。

切换到那个 ( image: portainer/portainer-ce:alpine) 后,图标似乎又可以工作了。我不知道常规图像的问题是什么,但这暂时解决了它。

PS:我曾尝试在 Traefik 上使用 Access-Control 标头,但这没有帮助。我猜这是 Portainer 的代码本身的问题。

于 2020-10-08T14:06:33.063 回答
0

您可以尝试刷新您的 DNS 缓存吗?在 Chrome 中“chrome://net-internals/#dns”进入 URL 栏并按下回车键。然后单击“清除主机缓存”然后刷新您的搬运工页面

于 2020-10-08T01:24:19.590 回答
0

如果其他人遇到此问题,我通过删除浏览器缓存或仅使用 CTRL+Shift+R 进行完全刷新来解决此问题

于 2021-12-10T23:31:43.943 回答