# Rancher server behind Traefik

**URL:** <https://forums.suse.com/t/rancher-server-behind-traefik/4263>\
**Category:** Rancher 1.x\
**Created:** [October 11, 2016, 8:44pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263 "2016-10-11T20:44:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobru](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/tobru/32/4879_2.png) [@tobru](https://forums.suse.com/u/tobru)\
**Post date:** [October 11, 2016, 8:44pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/1 "2016-10-11T20:44:24Z")

</div>

I’d like to run the Rancher server behind Traefik so that Traefik is the HTTPS entrypoint with Let’s Encrypt certificate. Reading [http://docs.rancher.com/rancher/v1.2/en/installing-rancher/installing-server/basic-ssl-config/](http://docs.rancher.com/rancher/v1.2/en/installing-rancher/installing-server/basic-ssl-config/) it looks like there is some additional configuration needed in terms of setting headers. So is it possible to run Rancher server behind Traefik?

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [October 12, 2016, 9:56am UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/2 "2016-10-12T09:56:27Z")

</div>

I can’t think of any reason why not. I use HAProxy and it works without these seemingly redundant parts described on the page you reference:

```auto
  acl is_websocket hdr(Upgrade) -i WebSocket
  acl is_websocket hdr_beg(Host) -i ws
  use_backend rancher_servers if is_websocket

```

I do add this header and value (as detailed in the Apache config on that page):

```auto
X-Forwarded-Proto "https

```

But it’s pretty redundant as I make use of HSTS (Strict-Transport-Security header).

Should you care, I also add a number of other security related headers: X-Frame-Options, X-XSS-Protection and X-Content-Type-Options. I also delete the Server header.

I did add the **secure** and **httponly** flags to all cookies but had some issues - I’ve not revisited this yet.

I also do mutual TLS auth, TLS CN restriction, target FQDN restriction and source IP restriction.

---

<div class="post-metadata">

**Author:** ![tobru](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/tobru/32/4879_2.png) [@tobru](https://forums.suse.com/u/tobru)\
**Post date:** [October 12, 2016, 8:48pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/3 "2016-10-12T20:48:47Z")

</div>

> [@sjiveson](#):
>
> I can’t think of any reason why not

I think Traefik lacks the support to add headers like the “Upgrade” header, but I’m not sure. At the end, I’m not sure if Traefik supports WebSocket or not, the documentation is not that helpful here.

Nevertheless, I tried to put Rancher behind Traefik with the following configuration:

```
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
      entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[file]

# rules
[backends]
  [backends.rancher]
    [backends.rancher.servers.server1]
    url = "http://myinternalrancher.example.com:8080"

[frontends]
  [frontends.rancher]
  backend = "rancher"
  entrypoints = ["http", "https"]
    [frontends.rancher.routes.default]
    rule = "Host:rancher.example.com"

```

Rancher is now reachable through Traefik, but login is not possible. I’m always sent back to the Login page, even with the correct credentials.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [October 13, 2016, 10:03am UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/4 "2016-10-13T10:03:43Z")

</div>

I think I initially had the same issue with HAProxy now that you mention it. Most likely this issue is because the X-Forwarded-Proto header isn’t inserted by Traefik. You could test this by removing the redirect on the http entrypoint perhaps?

Also, I don’t see any TLS configuration for the cert and key?

---

<div class="post-metadata">

**Author:** ![tobru](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/tobru/32/4879_2.png) [@tobru](https://forums.suse.com/u/tobru)\
**Post date:** [October 13, 2016, 11:39am UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/5 "2016-10-13T11:39:00Z")

</div>

I’ve tried your suggestion and tested it over plain HTTP, I still get redirect back to the login page. Certificates are coming from Let’s Encrypt, I omitted this in the example configuration. Here is my current complete configuration (changed hostnames).

```
[web]
address = ":8088"

[acme]
email = "mymail@example.com"
storageFile = "/etc/traefik/acme.json"
entryPoint = "https"

[[acme.domains]]
  main = "rancher.example.com"

logLevel = "DEBUG"
defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[file]

# rules
[backends]
  [backends.rancher]
    [backends.rancher.servers.server1]
    url = "http://rancherint.example.com:8080"

[frontends]
  [frontends.rancher]
  backend = "rancher"
  entrypoints = ["http", "https"]
    [frontends.rancher.routes.default]
    rule = "Host:rancher.example.com"
```

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [March 21, 2017, 2:09am UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/7 "2017-03-21T02:09:43Z")

</div>

`X-Forwarded-Proto` is not redundant; the server needs enough information from the request it receives from the balancer to reconstruct the original request URL and doesn’t have it if you don’t tell it that the original request was https.

Randomly changing cookie settings is also not going to work. The only important cookie (`token`) will already be `secure` when everything else is setup correctly. Most of the cookies exist only for the UI, which is entirely client-side, to read, so making them `httponly` makes them useless.

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [March 22, 2017, 1:13pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/8 "2017-03-22T13:13:31Z")

</div>

> [@vincent](#):
>
> Randomly changing cookie settings is also not going to work. The only important cookie (token) will already be secure when everything else is setup correctly. Most of the cookies exist only for the UI, which is entirely client-side, to read, so making them httponly makes them useless.

Apologies for the misinformed statements in my earlier post, I’d correct them if I could.

---

<div class="post-metadata">

**Author:** ![paulo.leal](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@paulo.leal](https://forums.suse.com/u/paulo.leal)\
**Post date:** [May 18, 2017, 9:24pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/9 "2017-05-18T21:24:50Z")

</div>

I am facing a similar problem. Have you come to a solution?

---

<div class="post-metadata">

**Author:** ![mholasek](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mholasek](https://forums.suse.com/u/mholasek)\
**Post date:** [May 26, 2017, 2:14pm UTC](https://forums.suse.com/t/rancher-server-behind-traefik/4263/10 "2017-05-26T14:14:09Z")

</div>

You have to add "passHostHeader = true"  
Sample is here: [https://docs.traefik.io/toml/#file-backend](https://docs.traefik.io/toml/#file-backend)

Used: traefik 1.3.0 rc3 and rancher 1.6.0
