RedirectScheme

Redirecting the Client to a Different Scheme/Port

RedirectScheme redirect request from a scheme to another.

Configuration Examples

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  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
  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
  3. "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
  4. }
  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. scheme = "https"
  5. permanent = true
  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. scheme: https
  7. permanent: true

Configuration Options

permanent

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

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  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
  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
  3. }
  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. # ...
  5. permanent = true
  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. # ...
  7. permanent: true

scheme

The scheme option defines the scheme of the new url.

  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  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
  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
  3. }
  1. # Redirect to https
  2. labels:
  3. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. scheme = "https"
  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. scheme: https

port

The port option defines the port of the new url.

  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
  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
  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
  1. "labels": {
  2. "traefik.http.middlewares.test-redirectscheme.redirectscheme.port": "443"
  3. }
  1. # Redirect to https
  2. labels:
  3. # ...
  4. - "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
  1. # Redirect to https
  2. [http.middlewares]
  3. [http.middlewares.test-redirectscheme.redirectScheme]
  4. # ...
  5. port = 443
  1. # Redirect to https
  2. http:
  3. middlewares:
  4. test-redirectscheme:
  5. redirectScheme:
  6. # ...
  7. port: 443