> ## Documentation Index
> Fetch the complete documentation index at: https://www.datum.net/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Agent home for Datum, with what it is, pricing, and how to act: https://agents.datum.net
> If you can only fetch URLs: read https://www.datum.net/docs/llms.txt in full and open the most specific page for the task. Commands, limits, and field paths are on task, operations, and limits pages, not on section overviews. Pages described as "Documentation is coming soon" are placeholders.
> If you have a shell or can save files: download https://www.datum.net/docs/llms-full.txt (every page, about 740 KB) once and search it with grep, instead of fetching pages one at a time.
> datumctl describes itself: `datumctl api-resources` lists resource types and `datumctl explain <resource>` shows a schema. To act on live resources, use Datum MCP or datumctl. To search the docs, use the Docs MCP server at https://www.datum.net/docs/mcp.

# Path-Based Routing with HTTPProxy

> Route requests to different backends based on URL paths using a Datum HTTPProxy.

The example routes one exact path to a dedicated backend and sends all remaining traffic to a default backend.

***

## Overview

Path-based routing lets you split traffic across backends based on the URL path, without changing your application or DNS.

At a high level, this setup:

1. Defines an **exact** path match for a specific route (e.g., `/login`)
2. Adds a **catch-all** prefix rule for all other traffic
3. Applies both rules in a single `HTTPProxy` resource

***

## Prerequisites

* `datumctl` installed and authenticated
* A valid **Project**

Verify access:

```bash theme={null}
datumctl get httpproxy
```

***

## Configuration steps

### Step 1: Set variables

> [tab] macOS / Linux
>
> ```bash theme={null}
> PROJECT="your-project-id"
> NAMESPACE="default"
> PROXY_NAME="my-proxy"
> HOSTNAME="app.example.com"
> ```

> [tab] Windows (PowerShell)
>
> ```powershell theme={null}
> $PROJECT    = "your-project-id"
> $NAMESPACE  = "default"
> $PROXY_NAME = "my-proxy"
> $HOSTNAME   = "app.example.com"
> ```

***

### Step 2: Apply path routing configuration

The `/login` path is matched exactly. All other requests fall through to the catch-all `/` rule.

Place the exact match rule **before** the catch-all. Rules are evaluated in order, and a prefix of `/` matches everything.

> [!NOTE]
>
> A rule can list up to 16 backends with a `weight` on each to split traffic. This guide uses one backend per rule.

> [tab] macOS / Linux
>
> ```bash theme={null}
> cat <<EOF | datumctl apply --project $PROJECT --namespace $NAMESPACE -f -
> apiVersion: networking.datumapis.com/v1alpha
> kind: HTTPProxy
> metadata:
>   name: $PROXY_NAME
> spec:
>   hostnames:
>   - $HOSTNAME
>   rules:
>   - name: login-exact
>     matches:
>     - path:
>         type: Exact
>         value: /login
>     backends:
>     - endpoint: https://auth-origin.example
>
>   - name: catch-all
>     matches:
>     - path:
>         type: PathPrefix
>         value: /
>     backends:
>     - endpoint: https://web-origin.example
> EOF
> ```

> [tab] Windows (PowerShell)
>
> ```powershell theme={null}
> @"
> apiVersion: networking.datumapis.com/v1alpha
> kind: HTTPProxy
> metadata:
>   name: $PROXY_NAME
> spec:
>   hostnames:
>   - $HOSTNAME
>   rules:
>   - name: login-exact
>     matches:
>     - path:
>         type: Exact
>         value: /login
>     backends:
>     - endpoint: https://auth-origin.example
>
>   - name: catch-all
>     matches:
>     - path:
>         type: PathPrefix
>         value: /
>     backends:
>     - endpoint: https://web-origin.example
> "@ | datumctl apply --project $PROJECT --namespace $NAMESPACE -f -
> ```

***

## Verification

### Exact path match

```bash theme={null}
curl -v https://app.example.com/login
```

Expected: request reaches `auth-origin.example`.

***

### Negative test: exact is truly exact

```bash theme={null}
curl -v https://app.example.com/login/reset
```

Expected: `/login/reset` does **not** match the `Exact /login` rule and falls through to the catch-all backend. Verify this to confirm the exact match boundary is working correctly.

***

### Catch-all

```bash theme={null}
curl -v https://app.example.com/
```

Expected: request reaches `web-origin.example`.

***

## Cleanup

> [tab] macOS / Linux
>
> ```bash theme={null}
> datumctl delete httpproxy $PROXY_NAME \
>   --project $PROJECT --namespace $NAMESPACE --ignore-not-found
> ```

> [tab] Windows (PowerShell)
>
> ```powershell theme={null}
> datumctl delete httpproxy $PROXY_NAME `
>   --project $PROJECT --namespace $NAMESPACE --ignore-not-found
> ```

***

## Best practices

* Always include a `PathPrefix /` catch-all so no requests are dropped unexpectedly
* Place more-specific rules (e.g., `Exact`, longer prefixes) before less-specific ones
* Use distinct, descriptive rule `name` values — they appear in logs and aid debugging
* Test both the matching path and a near-miss (e.g., `/login/reset`) to confirm exact boundaries

***

## Summary

* Path-based routing is configured using a **`HTTPProxy`** resource at `networking.datumapis.com/v1alpha`
* Use `type: Exact` for single endpoints like `/login`
* Use `type: PathPrefix` with value `/` as a catch-all for all remaining traffic
* Rule order matters — place specific matches before the catch-all


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.