# Https requests not working for docker/nextcloud (plain http request sent to https port)

**URL:** <https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [November 7, 2019, 12:46pm UTC](https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847 "2019-11-07T12:46:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cantello](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cantello/32/1034_2.png) [@Cantello](https://community.traefik.io/u/Cantello)\
**Post date:** [November 7, 2019, 12:46pm UTC](https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847/1 "2019-11-07T12:46:27Z")

</div>

Dear all!

I am trying to secure my nextcloud installation (docker on Ubuntu 18.04 on ESXi 6.7) with traefik & letsencrypt. However, when I try to access the NC instance via https, my browser either redirects to https://\_/ (Vivaldi) or gives an error ("The plain HTTP request was sent to HTTPS port", curl / Firefox).

The dashboard works via https as well as another simple whoami container. Only nextcloud does not work as expected and I am losing my mind over what I could have done wrong. So far I mostly followed guides & tutorials (starting with the excellent one on medium), modifying and adding where necessary. Maybe I have created an amalgamate of several configurations, which leads to the current problems but even restarting from scratch does not work anymore.

My config files:

docker-compose.yml

```auto
version: '3'

services:
  traefik:
    image: traefik:v2.0.4
    container_name: traefik
    restart: unless-stopped
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /root/traefik/acme.json:/acme.json
      - /root/traefik/traefik.yml:/traefik.yml:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=http"
      - "traefik.http.routers.traefik.rule=Host(`traefik.domain.net`)"
      - "traefik.http.middlewares.traefik-auth.basicauth.users=user:pass"
      - "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
      - "traefik.http.routers.traefik-secure.entrypoints=https"
      - "traefik.http.routers.traefik-secure.rule=Host(`traefik.domain.net`)"
      - "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
      - "traefik.http.routers.traefik-secure.tls=true"
      - "traefik.http.routers.traefik-secure.tls.certresolver=http"
      - "traefik.http.routers.traefik-secure.service=api@internal"

  whoami:
    image: "containous/whoami"
    container_name: "simple-whoami"
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.domain.net`)"
      - "traefik.http.routers.whoami.entrypoints=https"
      - "traefik.http.routers.whoami.tls.certresolver=http"

  nextcloud:
    image: linuxserver/nextcloud
    container_name: "nextcloud"
    networks:
      - proxy
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=Europe/Berlin
    volumes:
      - /home/dockeruser/nextcloud:/config
      - /home/dockeruser/nextcloud_data:/data
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud-secure.entrypoints=https"
      - "traefik.http.routers.nextcloud-secure.rule=Host(`nextcloud.domain.net`)"
      - "traefik.http.routers.nextcloud-secure.tls=true"
      - "traefik.http.routers.nextcloud-secure.tls.certresolver=http"
      - "traefik.http.routers.nextcloud-secure.service=nextcloud"

networks:
  proxy:
    external: true

```

traefik.yml

```auto
api:
  dashboard: true

log:
  level: DEBUG

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

certificatesResolvers:
  http:
    acme:
      email: email@domain.net
      storage: acme.json
      httpChallenge:
        entryPoint: http

```

last part of `docker-compose logs`

```auto
traefik | time="2019-11-07T12:30:39Z" level=debug msg="vulcand/oxy/roundrobin/rr: completed ServeHttp on request" Request="{\"M
ethod\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/\",\"RawPath\":\"\",\"ForceQuery\":
false,\"RawQuery\":\"\",\"Fragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"*/*\"]
,\"User-Agent\":[\"curl/7.58.0\"],\"X-Forwarded-Host\":[\"nextcloud.domain.net\"],\"X-Forwarded-Port\":[\"443\"],\"X-Forwarded-P
roto\":[\"https\"],\"X-Forwarded-Server\":[\"b3bbad79f113\"],\"X-Real-Ip\":[\"ip-address\"]},\"ContentLength\":0,\"TransferEncod
ing\":null,\"Host\":\"nextcloud.domain.net\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAdd
r\":\"ip-address:36902\",\"RequestURI\":\"/\",\"TLS\":null}"

```

Any ideas?  
In case you were wondering why the traefik directory is under /root - I first tried /opt/traefik but somehow it did not recognize the docker-compose.yml there. A simple cp to /root was sufficient to make it run.

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [November 7, 2019, 10:10pm UTC](https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847/2 "2019-11-07T22:10:11Z")

</div>

Use the config files that you posted above. Discard all the experiments, that you've done after posting.

Add this to your traefik.yml:

```auto
serversTransport:
  insecureSkipVerify: true

```

Modify your docker-compose.yaml, so that NC section labels look like this:

```auto
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nextcloud-secure.entrypoints=https"
      - "traefik.http.routers.nextcloud-secure.rule=Host(`nextcloud.domain.net`)"
      - "traefik.http.routers.nextcloud-secure.tls=true"
      - "traefik.http.routers.nextcloud-secure.tls.certresolver=http"
      - "traefik.http.routers.nextcloud-secure.service=nextcloud"
      - "traefik.http.services.nextcloud.loadbalancer.server.port=443"
      - "traefik.http.services.nextcloud.loadbalancer.server.scheme=https"

```

---

<div class="post-metadata">

**Author:** ![Cantello](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cantello/32/1034_2.png) [@Cantello](https://community.traefik.io/u/Cantello)\
**Post date:** [November 8, 2019, 8:54am UTC](https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847/3 "2019-11-08T08:54:35Z")

</div>

This works, thanks! 🙂

The only modifications were the loadbalancer service and `insecureSkipVerify`, correct? Could you elaborate on why the SSL certificate should not be verified? I thought it was a regular, valid, letsencrypt-issued certificate. However, it works, so maybe I should not think too hard about it.

---

<div class="post-metadata">

**Author:** ![zespri](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/zespri/32/310_2.png) [@zespri](https://community.traefik.io/u/zespri)\
**Post date:** [November 8, 2019, 9:38am UTC](https://community.traefik.io/t/https-requests-not-working-for-docker-nextcloud-plain-http-request-sent-to-https-port/2847/4 "2019-11-08T09:38:11Z")

</div>

> [@Cantello](#):
>
> The only modifications were the loadbalancer service and `insecureSkipVerify` , correct

Yes

> [@Cantello](#):
>
> Could you elaborate on why the SSL certificate should not be verified?

> <https://github.com/traefik/traefik/issues/5732>
>
> \### Do you want to request a \*feature\* or report a \*bug\*?
> 
> \<!--
> DO NOT FILE I…SSUES FOR GENERAL SUPPORT QUESTIONS.
> 
> The issue tracker is for reporting bugs and feature requests only.
> For end-user related support questions, please refer to one of the following:
> 
> \- the Traefik community forum: https://community.containo.us/
> 
> \--\>
> 
> Bug
> 
> \<!--
> 
> The configurations between 1.X and 2.X are NOT compatible.
> Please have a look here https://docs.traefik.io/v2.0/getting-started/configuration-overview/.
> 
> \--\>
> 
> \### What did you do?
> 
> I tried to run traefik in a docker swarm and wanted to expose the dashboard as shown in the docs here: https://docs.traefik.io/operations/dashboard/#secure-mode
> 
> \### What did you expect to see?
> 
> The dashboard on \`http://127.0.0.11/dashboard/\`
> 
> \### What did you see instead?
> 
> A 404 from traefik
> 
> \### Output of \`traefik version\`: (\_What version of Traefik are you using?\_)
> 
> \<!--
> \`latest\` is not considered as a valid version.
> 
> For the Traefik Docker image:
> docker run \[IMAGE\] version
> ex: docker run traefik version
> 
> \--\>
> 
> \`\`\`
> Version: 2.0.2
> Codename: montdor
> Go version: go1.13.1
> Built: 2019-10-09T19:26:05Z
> OS/Arch: linux/amd64
> \`\`\`
> 
> \### What is your environment & configuration (arguments, toml, provider, platform, ...)?
> 
> \`\`\`yml
> version: '3.7'
> services:
> traefik:
> image: traefik:latest
> ports:
> - 80:80
> - 443:443
> deploy:
> replicas: 1
> placement:
> constraints:
> - node.role == manager
> labels:
> - traefik.enable=true
> - traefik.http.routers.traefik\_http.rule=Host(\`127.0.0.11\`)
> - traefik.http.routers.traefik\_http.service=api@internal
> - traefik.http.routers.traefik\_http.entrypoints=http
> volumes:
> - /var/run/docker.sock:/var/run/docker.sock
> command: \>
> --providers.docker
> --providers.docker.exposedbydefault=false
> --providers.docker.swarmmode=true
> --entryPoints.http.address=":80"
> --entryPoints.https.address=":443"
> --accesslog
> --log.level=INFO
> --api=true
> --api.dashboard=true
> \`\`\`
> 
> \<!--
> Add more configuration information here.
> \--\>
> 
> 
> \### If applicable, please paste the log output in DEBUG level (\`--log.level=DEBUG\` switch)
> 
> \`\`\`
> level=error msg="port is missing" providerName=docker container=traefik-traefik-1jvz83nonxx53q9eel9r4cwlg
> \`\`\`
> 
> Traefik seems to ignore configurations of a docker service if they are missing a service definition setting a loadbalancer port.
> Since \`api@internal\` is an internal service which is already defined and has no port, I didn't define one.
> However, if I add a \*\*dummy service\*\* with a port, \*\*the Dashboard works fine\*\*:
> 
> \`\`\`yml
> ...
> labels:
> - traefik.enable=true
> - traefik.http.services.dummyService.loadbalancer.server.port=1337
> - traefik.http.routers.traefik\_http.rule=Host(\`127.0.0.11\`)
> - traefik.http.routers.traefik\_http.service=api@internal
> - traefik.http.routers.traefik\_http.entrypoints=http
> ...
> \`\`\`
> 
> I did some more experiments:
> 
> \`\`\`yml
> \# Route and Services work fine:
> whoami:
> image: containous/whoami
> deploy:
> replicas: 2
> labels:
> - traefik.enable=true
> - traefik.http.services.whoami.loadbalancer.server.port=80
> - traefik.http.routers.whoami\_http.rule=Host(\`127.0.0.12\`)
> - traefik.http.routers.whoami\_http.service=whoami
> - traefik.http.routers.whoami\_http.entrypoints=http
> 
> \# Route for whoami2 is ignored because of missing port:
> whoami2:
> image: containous/whoami
> deploy:
> replicas: 1
> labels:
> - traefik.enable=true
> - traefik.http.routers.whoami2\_http.rule=Host(\`127.0.0.13\`)
> - traefik.http.routers.whoami2\_http.service=whoami
> - traefik.http.routers.whoami2\_http.entrypoints=http
>       
> \# Route for whoami3 is ignored because of missing port:
> whoami3:
> image: containous/whoami
> deploy:
> replicas: 1
> labels:
> - traefik.enable=true
> - traefik.http.routers.whoami3\_http.rule=Host(\`127.0.0.14\`)
> 
> \# Route for whoami4 is parsed and served by whoami4:
> whoami4:
> image: containous/whoami
> deploy:
> replicas: 1
> labels:
> - traefik.enable=true
> - traefik.http.services.whoami4.loadbalancer.server.port=80
> - traefik.http.routers.whoami4\_http.rule=Host(\`127.0.0.15\`)
> 
> \# Route for whoami5 is parsed and served by whoami:
> whoami5:
> image: containous/whoami
> deploy:
> replicas: 1
> labels:
> - traefik.enable=true
> - traefik.http.services.whoami5.loadbalancer.server.port=1337
> - traefik.http.routers.whoami5\_http.rule=Host(\`127.0.0.16\`)
> - traefik.http.routers.whoami5\_http.service=whoami
> \`\`\`
> Errors here:
> \`\`\`
> level=error msg="port is missing" providerName=docker container=traefik-whoami2-lvaeohb9ycx9g8vqs5bhhep5b
> level=error msg="port is missing" providerName=docker container=traefik-whoami3-mpr8w2rl8lx21b13vt3c3nm0e
> \`\`\`
> 
> It looks like traefik requires a \`traefik.http.services.\*.loadbalancer.server.port\` label on every service, or it will discard the configuration. Name, existence and port of the service are completely irrelevant.
> 
> Traefik should not require a loadbalancer port definition for each docker service, because a router can also reference an internal service or a service defined elsewhere and thus defining a service/loadbalancer is pointless.
