404错误和traefik和nextcloud的“许多重定向”

时间:2018-11-20 14:08:11

标签: docker-compose traefik

我使用Traefik进行某些服务的反向代理。但是有些东西没有按预期工作。我认为这可能是港口冲突。使用端口示例192.168.1.10:8080时,我被重定向到Traefik仪表板。但是,当访问192.168.1.10时,我想结束于Nextcloud服务,但是却收到404错误。

这是我的docker-compose.yml文件:

    version: "3.6"
    services:

    ### TRAEFIK REVERSE PROXY WITH LETTS ECRYPT FOR DOCKER MEDIA SERVER ###
      traefik:
        hostname: traefik
        image: traefik:latest
        container_name: traefik
        restart: always
        domainname: ${DOMAINNAME}
        networks:
          - default
          - traefik_proxy
        ports:
          - "80:80"
          - "443:443"
    #      - "8080:8080"
        environment:
          - CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
          - CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
        labels:
          - "traefik.enable=true"
          - "traefik.backend=traefik"
          - "traefik.frontend.rule=Host:traefik.${DOMAINNAME}"  
          - "traefik.port=80"
          - "traefik.docker.network=traefik_proxy"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock:ro
          - ${USERDIR}/docker/traefik:/etc/traefik
          - ${USERDIR}/docker/shared:/shared

    ### NextCloud – Your Own Cloud Storage ### with redis https://github.com/nextcloud/docker/issues/140
      nextcloud:
        container_name: nextcloud
        depends_on:
          - traefik
          - mariadb
          - redis
        restart: always
        image: linuxserver/nextcloud
        volumes:
          - ${USERDIR}/docker/nextcloud:/config
          - ${USERDIR}/shared_data:/data # Path to data you want to share/sync
          - ${USERDIR}/docker/shared:/shared
        ports:
           - "9059:443"
        environment:
          - PUID=${PUID}
          - PGID=${PGID}
        networks:
          - traefik_proxy
          - default
        labels:
          - "traefik.enable=true"
          - "traefik.backend=nextcloud"
          - "traefik.frontend.rule=Host:nextcloud.${DOMAINNAME}"
          - "traefik.port=80"
          - "traefik.protocol=https"
          - "traefik.docker.network=traefik_proxy"

这是我的Traefik.toml文件:

    #debug = true
    logLevel = "DEBUG" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
    InsecureSkipVerify = true
    defaultEntryPoints = ["https", "http"]

    # WEB interface of Traefik - it will show web page with overview of frontend and backend configurations
    [web]
    address = ":8080"
      [web.auth.basic]
      usersFile = "/shared/.htpasswd"

    # Force HTTPS
    [entryPoints]
      [entryPoints.http]
      address = ":80"
        [entryPoints.http.redirect]
        entryPoint = "https"
      [entryPoints.https]
      address = ":443"
        [entryPoints.https.tls]

访问192.168.1.10时,预期结果达到了nextcloud。

1 个答案:

答案 0 :(得分:2)

您在nextcloud下的标签告诉traefik将符合前端规则的流量路由到该服务的端口80

- "traefik.port=80"

当您的nextcloud服务仅公开端口443时。将标签更改为使用端口443。

如果您希望访问192.168.1.10时访问nextcloud,则前端规则应为

- "traefik.frontend.rule=Host:${DOMAINNAME}"

最后在localhost上进行测试时,最好使用curl进行测试,以避免其他麻烦

curl -H Host:whoami0.traefik http://localhost