You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/content/how-to/traffic-management/redirects-and-rewrites.md
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Learn how to redirect or rewrite your HTTP traffic using NGINX Gateway Fabric.
11
11
12
12
[HTTPRoute](https://gateway-api.sigs.k8s.io/api-types/httproute/) filters can be used to configure HTTP redirects or rewrites. Redirects return HTTP 3XX responses to a client, instructing it to retrieve a different resource. Rewrites modify components of a client request (such as hostname and/or path) before proxying it upstream.
13
13
14
-
In this guide, we will set up the coffee application to demonstrate path URL rewriting and the tea and soda applications to showcase path-based request redirection.. For an introduction to exposing your application, we recommend that you follow the [basic guide]({{< relref "/how-to/traffic-management/routing-traffic-to-your-app.md" >}}) first.
14
+
In this guide, we will set up the coffee application to demonstrate path URL rewriting, and the tea and soda applications to showcase path-based request redirection. For an introduction to exposing your application, we recommend that you follow the [basic guide]({{< relref "/how-to/traffic-management/routing-traffic-to-your-app.md" >}}) first.
15
15
16
16
To see an example of a redirect using scheme and port, see the [HTTPS Termination]({{< relref "/how-to/traffic-management/https-termination.md" >}}) guide.
17
17
@@ -37,7 +37,7 @@ We will configure a common gateway for the `URLRewrite` and `RequestRedirect` fi
37
37
38
38
---
39
39
40
-
### Deploy the Gateway API resources for the applications
40
+
### Deploy the Gateway resource for the applications
41
41
42
42
The [Gateway](https://gateway-api.sigs.k8s.io/api-types/gateway/) resource is typically deployed by the [Cluster Operator](https://gateway-api.sigs.k8s.io/concepts/roles-and-personas/#roles-and-personas_1). This Gateway defines a single listener on port 80. Since no hostname is specified, this listener matches on all hostnames. To deploy the Gateway:
43
43
@@ -60,11 +60,11 @@ EOF
60
60
61
61
## URLRewrite example
62
62
63
-
This examples demonstrates how to rewrite the traffic uri for a simple coffee application. A HTTPRoute resource is used to define two `URLRewrite` filters that will rewrite requests. You can verify the server responds with the rewritten uri.
63
+
This examples demonstrates how to rewrite the traffic URL for a simple coffee application. An HTTPRoute resource is used to define two `URLRewrite` filters that will rewrite requests. You can verify the server responds with the rewritten URL.
64
64
65
65
---
66
66
67
-
### Setup
67
+
### Deploy the coffee application
68
68
69
69
Create the **coffee** application in Kubernetes by copying and pasting the following block into your terminal:
70
70
@@ -248,7 +248,7 @@ URI: /prices?test=v1&test=v2
248
248
249
249
## RequestRedirect example
250
250
251
-
This example demonstrates how to redirect the traffic to a new location for a tea and soda applications. We'll examine how request redirects works using the `RequestRedirect`filter by creating four HTTPRoutes: two for redirecting requests to a new location and other two to define the destination location blocks for the redirected traffic.
251
+
This example demonstrates how to redirect the traffic to a new location for the tea and soda applications, using `RequestRedirect`filters.
252
252
253
253
---
254
254
@@ -326,7 +326,7 @@ spec:
326
326
EOF
327
327
```
328
328
329
-
This will create the **tea** and **soda**service and a deployment. Run the following command to verify the resources were created:
329
+
This will create the **tea** and **soda**services and deployments. Run the following command to verify the resources were created:
We will define two HTTPRoutes for **tea** application: `tea`, which specifies the destination location block to handle redirected requests, and `tea-redirect` that redirect requests as follows:
352
+
We will define two HTTPRoutes for the **tea** application: `tea`, which specifies the destination to handle redirected requests, and `tea-redirect` that redirect requests as follows:
353
353
354
354
-`http://cafe.example.com/tea` to `http://cafe.example.com/organic`
355
355
-`http://cafe.example.com/tea/origin` to `http://cafe.example.com/organic/origin`
356
356
357
-
The two HTTPRoutes defined for **soda** application: `soda`, which specifies the destination location block to handle redirected requests, and `soda-redirect` that redirect requests as follows:
357
+
We will also define two HTTPRoutes defined for the **soda** application: `soda`, which specifies the destination to handle redirected requests, and `soda-redirect` that redirect requests as follows:
358
358
359
359
-`http://cafe.example.com/soda` to `http://cafe.example.com/flavors`
360
360
-`http://cafe.example.com/soda/pepsi` to `http://cafe.example.com/flavors`
@@ -453,7 +453,7 @@ EOF
453
453
454
454
### Send traffic
455
455
456
-
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our tea and soda application to verify the redirect is successful. We will use curl's `--include` option to print the response headers (we are interested in the `Location` header) and `-L` to follow redirects, ensuring that the user fetches the final destination after encountering HTTP 3xx redirect response.
456
+
Using the external IP address and port for NGINX Gateway Fabric, we can send traffic to our tea and soda applications to verify the redirect is successful. We will use curl's `--include` option to print the response headers (we are interested in the `Location` header) and `-L` to follow redirects, ensuring that the user fetches the final destination after encountering HTTP 3xx redirect response.
457
457
458
458
{{< note >}}If you have a DNS record allocated for `cafe.example.com`, you can send the request directly to that hostname, without needing to resolve.{{< /note >}}
0 commit comments