0

I currently have a hard time updating my traefik v1 containers to v2. I set up a traefik container with automatic http->https forwarding. Now I want to get portainer running with the following docker-compose file:

version: '3.3'
volumes:
  portainer: {}
networks:
  web:
    external: true
services:
  portainer:
    image: portainer/portainer:latest
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer_data:/data
    command: |
      --no-analytics
      --data /data
      --admin-password "the_hashed_password"
      -H unix:///var/run/docker.sock
    networks:
      web:
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.entrypoints=websecure"
      - "traefik.http.routers.portainer.rule=Host(`portainer.myserver.domain`)"
      - "traefik.http.services.portainer.loadbalancer.server.port=9000"
      - "traefik.http.routers.portainer.tls=true"
      - "traefik.http.routers.portainer.tls.certresolver=leresolver"
      - "traefik.http.routers.portainer.middlewares=authportainer"
      # generate with: sudo docker run --rm -ti xmartlabs/htpasswd user password
      - "traefik.http.middlewares.authportainer.basicauth.users=myuser:my_hashed_password"

Now when I start the container with docker-compose up I get:

portainer_1  | 2020/04/19 16:10:04 Starting Portainer 1.23.2 on :9000
...
portainer_1  | 2020/04/19 16:10:04 server: Listening on 0.0.0.0:8000...

Accessing http://portainer.myserver.domain correctly forwards to https://portainer.myserver.domain. After authenticating with myuser, an empty page is shown with a fading message toast "Failure. Unable to retrieve server settings and status". With traefik v1 the setup used to work. What I don't understand is if I need to do anything with port 8000 (which I didn't in the old working environment).

How does one debug such a scenario?
What is wrong with my docker-compose file?

P.S. For brevity, I omitted the traefik configuration file. If wanted, I will add it (it works with simple containers).

4

3 回答 3

2

经过太多小时后,我想出了两件事:

  1. 浏览器在这里/有问题
  2. 最新的不是它所说的(那个无关但在调试过程中发生在我身上)

关于浏览器 - 我使用 Firefox 78.0.1 并且总是在一台特定机器上使用 docker。似乎缓存了一些不应该缓存的数据,缓存导致了错误页面。我不知道 portainer 是否在浏览器缓存中存储了一些数据(如 cookie),但是让它忘记站点见这里使 portainer 正常工作。请注意,这里按F5Shift+F5不起作用,重新启动浏览器也没有。

如果您遇到类似的问题,您也可以在私人窗口中加载页面。根据您的浏览器配置,这应该会阻止它使用以前缓存的数据。

于 2020-07-05T15:43:26.553 回答
2

我遇到了类似的问题,可以通过扩展路由器规则来解决它(另请参阅Traefik 文档。):

- "traefik.http.routers.portainer.rule=Host(`portainer.myserver.domain`) || (Host(`portainer.myserver.domain`) && PathPrefix(`/api`))"

这样,Traefik 现在应该正确路由 Portainer 前端的 api 请求。

希望这对你也有帮助!

PS关于您的调试问题,我通过检查浏览器的网络交互来解决这个问题,这表明所有调用都portainer.myserver.domain/api/xyz返回了404错误。

于 2020-06-18T13:13:11.517 回答
0

对我来说,这是一个缓存问题。

  1. 转到浏览器的开发控制台
  2. 打开“网络存储”
  3. 删除您的搬运工网址的本地存储(右键单击)
于 2022-01-06T15:29:03.133 回答