traefik/docs/content/middlewares/redirectscheme.md

254 lines
4.9 KiB
Markdown
Raw Normal View History

2019-04-08 17:14:08 +02:00
# RedirectScheme
Redirecting the Client to a Different Scheme/Port
{: .subtitle }
2019-09-10 14:40:05 +02:00
<!--
TODO: add schema
-->
2019-09-30 04:12:04 -03:00
RedirectScheme redirect request from a scheme to another.
## Configuration Examples
2019-04-03 14:32:04 +02:00
```yaml tab="Docker"
# Redirect to https
labels:
2019-09-23 17:00:06 +02:00
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
2020-02-17 11:04:04 +01:00
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
2019-04-03 14:32:04 +02:00
```
```yaml tab="Kubernetes"
# Redirect to https
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectscheme
spec:
redirectScheme:
scheme: https
2020-02-17 11:04:04 +01:00
permanent: true
2019-04-03 14:32:04 +02:00
```
2019-10-15 18:34:08 +03:00
```yaml tab="Consul Catalog"
# Redirect to https
labels:
2020-02-17 11:04:04 +01:00
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
2019-10-15 18:34:08 +03:00
```
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
2020-02-17 11:04:04 +01:00
"traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
}
```
2019-04-08 17:14:08 +02:00
```yaml tab="Rancher"
# Redirect to https
labels:
2019-09-23 17:00:06 +02:00
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
2020-02-17 11:04:04 +01:00
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
2019-04-08 17:14:08 +02:00
```
2019-07-22 09:58:04 +02:00
```toml tab="File (TOML)"
2019-04-03 14:32:04 +02:00
# Redirect to https
[http.middlewares]
2019-07-01 11:30:05 +02:00
[http.middlewares.test-redirectscheme.redirectScheme]
2019-04-03 14:32:04 +02:00
scheme = "https"
2020-02-17 11:04:04 +01:00
permanent = true
2019-04-03 14:32:04 +02:00
```
2019-07-22 09:58:04 +02:00
```yaml tab="File (YAML)"
# Redirect to https
http:
middlewares:
test-redirectscheme:
redirectScheme:
scheme: https
2020-02-17 11:04:04 +01:00
permanent: true
2019-07-22 09:58:04 +02:00
```
## Configuration Options
2019-04-03 14:32:04 +02:00
### `permanent`
Set the `permanent` option to `true` to apply a permanent redirection.
2020-02-17 11:04:04 +01:00
```yaml tab="Docker"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
```
```yaml tab="Kubernetes"
# Redirect to https
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectscheme
spec:
redirectScheme:
# ...
permanent: true
```
```yaml tab="Consul Catalog"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
```
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent": "true"
}
```
```yaml tab="Rancher"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
```
```toml tab="File (TOML)"
# Redirect to https
[http.middlewares]
[http.middlewares.test-redirectscheme.redirectScheme]
# ...
permanent = true
```
```yaml tab="File (YAML)"
# Redirect to https
http:
middlewares:
test-redirectscheme:
redirectScheme:
# ...
permanent: true
```
2019-04-03 14:32:04 +02:00
### `scheme`
The `scheme` option defines the scheme of the new url.
2020-02-17 11:04:04 +01:00
```yaml tab="Docker"
# Redirect to https
labels:
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
```
```yaml tab="Kubernetes"
# Redirect to https
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectscheme
spec:
redirectScheme:
scheme: https
```
```yaml tab="Consul Catalog"
# Redirect to https
labels:
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
```
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme": "https"
}
```
```yaml tab="Rancher"
# Redirect to https
labels:
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
```
```toml tab="File (TOML)"
# Redirect to https
[http.middlewares]
[http.middlewares.test-redirectscheme.redirectScheme]
scheme = "https"
```
```yaml tab="File (YAML)"
# Redirect to https
http:
middlewares:
test-redirectscheme:
redirectScheme:
scheme: https
```
2019-04-03 14:32:04 +02:00
### `port`
The `port` option defines the port of the new url.
2020-02-17 11:04:04 +01:00
```yaml tab="Docker"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
```
```yaml tab="Kubernetes"
# Redirect to https
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectscheme
spec:
redirectScheme:
# ...
2020-05-14 08:30:06 -07:00
port: "443"
2020-02-17 11:04:04 +01:00
```
```yaml tab="Consul Catalog"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
```
```json tab="Marathon"
"labels": {
"traefik.http.middlewares.test-redirectscheme.redirectscheme.port": "443"
}
```
```yaml tab="Rancher"
# Redirect to https
labels:
# ...
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.port=443"
```
```toml tab="File (TOML)"
# Redirect to https
[http.middlewares]
[http.middlewares.test-redirectscheme.redirectScheme]
# ...
port = 443
```
```yaml tab="File (YAML)"
# Redirect to https
http:
middlewares:
test-redirectscheme:
redirectScheme:
# ...
2020-05-14 08:30:06 -07:00
port: "443"
2020-02-17 11:04:04 +01:00
```
2020-05-14 08:30:06 -07:00
!!! info "Port in this configuration is a string, not a numeric value."