Traefik https redirection redirects to IP instead of Domain

I'm trying to use traefik in a VM which sits behind an nginx instance, which forwards any incoming traffic with http and https and the correct domain name to the VM. I want to set up traefik to redirect http to https in a docker-compose setup. My current config is

    image: traefik:v2.4
      - "--api.insecure=true"
      - "--providers.docker=true"

      # http
      - "--entrypoints.web.address=:80"

      # redirect to https
      - ""

      # https
      - "--entrypoints.websecure.address=:443"

      # lets encrypt setup
      - "${ACME_EMAIL}"
      - ""
      # staging lets encrypt server
      - "--certificatesresolvers.myresolver.acme.caserver="
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
      - pusher
      - front
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./lets-encrypt:/lets-encrypt

However, this doesn't work as expected, because it redirects from to https://xx.xx.xx.xx, i.e. the VMs ip address. How can I configure traefik to redirect to instead?

EDIT: formatting

Hi @tmahlburg

I think you will need to use proxyProtocol on your entrypoint(and nginx) when placed behind another proxy

thanks for the answer. I got it working another way: Setting "proxy_set_header Host $host" in the nginx configuration did the trick.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.