首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Traefik不加前缀

Traefik不加前缀
EN

Stack Overflow用户
提问于 2022-06-19 21:43:03
回答 1查看 157关注 0票数 2

我正试着建立我的第一个家乡。我已经有一些服务作为码头集装箱运行,也让Traefik与他们合作。现在,我想对我的PiHole实例执行同样的操作。我已经让它正常工作了,所以我可以通过导航到'pihole.local.myurl.com/admin‘来访问仪表板。但是,我想自动添加'/admin‘前缀。

我尝试过使用这个docker-compose.yml,但是前缀不会添加:

代码语言:javascript
复制
version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    restart: unless-stopped
    # For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
    networks:
      - proxy
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      #- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
      #- "8000:80/tcp"
    environment:
      TZ: 'Europe/Berlin'
      WEBPASSWORD: 'my_password'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
      - './resolv.conf:/etc/resolv.conf'
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.pihole.entrypoints=http"
      - "traefik.http.routers.pihole.rule=Host(`pihole.local.myurl.com`)"
      - "traefik.http.middlewares.pihole-prefix.addPrefix.prefix=/admin"
      - "traefik.http.routers.pihole.middlewares=pihole-prefix"
      - "traefik.http.middlewares.pihole-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.pihole.middlewares=pihole-https-redirect"
      - "traefik.http.routers.pihole-secure.entrypoints=https"
      - "traefik.http.routers.pihole-secure.rule=Host(`pihole.local.myurl.com`)"
      - "traefik.http.routers.pihole-secure.tls=true"
      - "traefik.http.routers.pihole-secure.service=pihole"
      - "traefik.http.services.pihole.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy"
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    #cap_add:
    #  - NET_ADMIN # Recommended but not required (DHCP needs NET_ADMIN)      

networks:
  proxy:
    external: true

我的船坞写作有错吗?

EN

回答 1

Stack Overflow用户

发布于 2022-11-17 00:07:20

您必须指定中间件的位置。在本例中,将@docker追加到正在调用中间件的路由器的行尾。(标签第5和第7行)

这里是我为Organizr撰写的文章,它既调用了本地定义的文件,也调用了独立的基于文件的中间件:

代码语言:javascript
复制
      - traefik.enable=true
      ## HTTP Routers
      - traefik.http.routers.organizr-rtr.entrypoints=https
      - traefik.http.routers.organizr-rtr.rule=Host(`$DOMAINNAME`) || Host(`www.$DOMAINNAME`)
      ## Middlewares
      - traefik.http.routers.organizr-rtr.middlewares=organizr-redirect@docker,secure-headers@file
      ## Middlewares - Redirect to www
      - traefik.http.middlewares.organizr-redirect.redirectregex.permanent=true
      - traefik.http.middlewares.organizr-redirect.redirectregex.regex=^http(?:s)?://$DOMAINNAME/(.*)
      - traefik.http.middlewares.organizr-redirect.redirectregex.replacement=https://www.$DOMAINNAME/$${1}
      ## HTTP Services
      - traefik.http.routers.organizr-rtr.service=organizr-svc
      - traefik.http.services.organizr-svc.loadbalancer.server.port=80
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72680527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档