RedirectScheme

Redirecting the Client to a Different Scheme/Port

RedirectScheme redirects requests from a scheme/port to another.

Configuration Examples

Docker

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

Kubernetes

  1. # Redirect to https
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: test-redirectscheme
  6. spec:
  7. redirectScheme:
  8. scheme: https
  9. permanent: true

Consul Catalog

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

Marathon

  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
  3. "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
  4. }

Rancher

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

File (YAML)

  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. scheme: https
  7. permanent: true

File (TOML)

  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. scheme = "https"
  5. permanent = true

Configuration Options

permanent

Set the permanent option to true to apply a permanent redirection.

Docker

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

Kubernetes

  1. # Redirect to https
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: test-redirectscheme
  6. spec:
  7. redirectScheme:
  8. # ...
  9. permanent: true

Consul Catalog

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

Marathon

  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
  3. }

Rancher

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"

File (YAML)

  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. # ...
  7. permanent: true

File (TOML)

  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. # ...
  5. permanent = true

scheme

The scheme option defines the scheme of the new URL.

Docker

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"

Kubernetes

  1. # Redirect to https
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: test-redirectscheme
  6. spec:
  7. redirectScheme:
  8. scheme: https

Consul Catalog

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"

Marathon

  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
  3. }

Rancher

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"

File (YAML)

  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. scheme: https

File (TOML)

  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. scheme = "https"

port

The port option defines the port of the new URL.

Docker

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"

Kubernetes

  1. # Redirect to https
  2. apiVersion: traefik.containo.us/v1alpha1
  3. kind: Middleware
  4. metadata:
  5. name: test-redirectscheme
  6. spec:
  7. redirectScheme:
  8. # ...
  9. port: "443"

Consul Catalog

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"

Marathon

  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.port": "443"
  3. }

Rancher

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"

File (YAML)

  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. # ...
  7. port: "443"

File (TOML)

  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. # ...
  5. port = 443

Port in this configuration is a string, not a numeric value.