|
| 1 | +# Reverse Proxy API Examples (port can be changed in AppHost) |
| 2 | +# The "/reverse-proxy-api" is the base path for the reverse proxy API, which is configured when adding |
| 3 | +# the reverse proxy API to the application builder. |
| 4 | +@Test_HostAddress = https://localhost:8443 |
| 5 | + |
| 6 | +# Get clusters |
| 7 | +# View the current clusters configured in the reverse proxy. |
| 8 | +GET {{Test_HostAddress}}/reverse-proxy-api/cluster |
| 9 | + |
| 10 | +### |
| 11 | +# Add cluster |
| 12 | +# Add a cluster that points to the catfact.ninja API. This cluster will be used in the route configuration |
| 13 | +# to forward requests to the catfact API. |
| 14 | +POST {{Test_HostAddress}}/reverse-proxy-api/cluster |
| 15 | +Content-Type: application/json |
| 16 | + |
| 17 | +{ |
| 18 | + "Clusters": [ |
| 19 | + { |
| 20 | + "ClusterId": "catfact-from-api", |
| 21 | + "Destinations": { |
| 22 | + "destination1": { |
| 23 | + "Address": "https://catfact.ninja/fact" |
| 24 | + } |
| 25 | + } |
| 26 | + } |
| 27 | + ], |
| 28 | + "AllowOverwrite": true |
| 29 | +} |
| 30 | + |
| 31 | +### |
| 32 | +# Get routes |
| 33 | +# View the current routes configured in the reverse proxy. After adding the route, you should see |
| 34 | +# the new route in the response. |
| 35 | +GET {{Test_HostAddress}}/reverse-proxy-api/route |
| 36 | + |
| 37 | +### |
| 38 | +# Add route |
| 39 | +# Add a route that matches requests to /catfact and forwards them to the catfact cluster. The route also |
| 40 | +# includes a transform to remove the /catfact prefix before forwarding the request to the destination. |
| 41 | +POST {{Test_HostAddress}}/reverse-proxy-api/route |
| 42 | +Content-Type: application/json |
| 43 | + |
| 44 | +{ |
| 45 | + "Routes": [ |
| 46 | + { |
| 47 | + "RouteId": "catfact-from-api", |
| 48 | + "ClusterId": "catfact-from-api", |
| 49 | + "Order": 100, |
| 50 | + "Match": { |
| 51 | + "Path": "catfact-from-api/{**catch-all}" |
| 52 | + }, |
| 53 | + "Transforms": [ |
| 54 | + { |
| 55 | + "PathRemovePrefix": "/catfact-from-api" |
| 56 | + } |
| 57 | + ] |
| 58 | + } |
| 59 | + ], |
| 60 | + "AllowOverwrite": true |
| 61 | +} |
0 commit comments