# Traefik https redirection redirects to IP instead of Domain

**URL:** <https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542>\
**Category:** Traefik v2\
**Tags:** letsencrypt-acme, docker\
**Created:** [May 5, 2021, 11:52am UTC](https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542 "2021-05-05T11:52:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmahlburg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tmahlburg/32/3742_2.png) [@tmahlburg](https://community.traefik.io/u/tmahlburg)\
**Post date:** [May 5, 2021, 11:52am UTC](https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542/1 "2021-05-05T11:52:46Z")

</div>

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

```auto
  reverse-proxy:
    image: traefik:v2.4
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"

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

      # redirect to https
      - "--entrypoints.web.http.redirections.entrypoint.to=websecure"

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

      # lets encrypt setup
      - "--certificatesresolvers.myresolver.acme.email=${ACME_EMAIL}"
      - "--certificatesresolvers.myresolver.acme.storage=/lets-encrypt/acme.json"
      # staging lets encrypt server
      - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
    ports:
      - "80:80"
      - "443:443"
      # The Web UI (enabled by --api.insecure=true)
      - "8080:8080"
    depends_on:
      - pusher
      - front
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./lets-encrypt:/lets-encrypt

```

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

EDIT: formatting

---

<div class="post-metadata">

**Author:** ![cakiwi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cakiwi/32/3205_2.png) [@cakiwi](https://community.traefik.io/u/cakiwi)\
**Post date:** [May 5, 2021, 3:43pm UTC](https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542/2 "2021-05-05T15:43:09Z")

</div>

Hi @tmahlburg

I think you will need to use proxyProtocol on your entrypoint(and nginx) when placed behind another proxy  
[https://doc.traefik.io/traefik/routing/entrypoints/#proxyprotocol](https://doc.traefik.io/traefik/routing/entrypoints/#proxyprotocol)

---

<div class="post-metadata">

**Author:** ![tmahlburg](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/tmahlburg/32/3742_2.png) [@tmahlburg](https://community.traefik.io/u/tmahlburg)\
**Post date:** [May 13, 2021, 2:55pm UTC](https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542/3 "2021-05-13T14:55:32Z")

</div>

Hey,  
thanks for the answer. I got it working another way: Setting "proxy\_set\_header Host $host" in the nginx configuration did the trick.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [May 16, 2021, 2:56pm UTC](https://community.traefik.io/t/traefik-https-redirection-redirects-to-ip-instead-of-domain/10542/4 "2021-05-16T14:56:24Z")

</div>

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