Skip to content

Commit

Permalink
fix(redirect): how to
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Rødseth Hansen <[email protected]>
Co-authored-by: Carl Hedgren <[email protected]>
  • Loading branch information
3 people committed Nov 13, 2024
1 parent 0bc8f49 commit 9c3a5f1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/workloads/application/how-to/redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ tags: [ application, how-to, redirect ]

# Redirect a client

To redirect traffic from one domain to another, you need to define an ingress for the old domain that redirects to the
To redirect traffic from one domain to another, you need to define an ingress `from` the old domain that redirects `to` the
new domain, with [`.spec.redirects[]`](../reference/application-spec.md#redirects).

The `redirects` field specifies URL redirects. It is structured as a mapping from a source URL to a target URL.

A successful redirect will return a `302 Moved Temporarily` HTTP status code with location header set to the target URL.

!!! note "Status code"
??? note "Status code for redirects"
The status code can not be overridden.

### Structure
Expand All @@ -21,16 +21,16 @@ apiVersion: nais.io/v1alpha1
kind: Application
spec:
ingress:
- https://<MY-SUBDOMAIN-OLD>.<ENVIRONMENT-DOMAIN>
- https://<MY-SUBDOMAIN-NEW>.<ENVIRONMENT-DOMAIN>
redirects:
- from: https://<MY-SUBDOMAIN-OLD>.<ENVIRONMENT-DOMAIN>
to: https://<MY-SUBDOMAIN>.<ENVIRONMENT-DOMAIN>
to: https://<MY-SUBDOMAIN-NEW>.<ENVIRONMENT-DOMAIN>
```
### Parameters
- **from**: *(string)* The source URL to be redirected. This is the URL where requests originate.
- **to**: *(string)* The target URL for the redirection. This is the URL where requests will be forwarded.
- **from**: *(string)* The source URL for the redirection. This is the URL that will be redirected.
- **to**: *(string)* The target URL for the redirection. This is the URL that the client will be redirected to.
### Usage Example
Expand All @@ -39,17 +39,17 @@ apiVersion: nais.io/v1alpha1
kind: Application
spec:
ingress:
- https://example-old.com
- https://example-new.com
redirects:
- from: "http://example-old.nais.io"
to: "http://example.nais.io"
to: "http://example-new.nais.io"
```
!!! warning "Redirect restrictions"
??? warning "Redirect restrictions"
The `from` and `to` URLs must be valid URLs.
The `from` URL must be a valid URL that is exposed by the application.
The `to` URL must be a valid URL that is exposed by the application.

In this example:

- Requests to `http://example-old.nais.io` are redirected to `http://example.nais.io`.
- Requests to `http://example-old.nais.io` are redirected to `http://example-new.nais.io`.

0 comments on commit 9c3a5f1

Please sign in to comment.