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

# Deploy a Consistent Maintenance Message with Traffic Policy

> Learn how to use Traffic Policy to immediately deploy a consistent maintenance message without needing to spin up a new backend service or change DNS records.

Whenever you're making infrastructure changes, a major upgrade to your services during planned downtime, or experiencing an incident, you still want to maintain a public-facing presence on your endpoints to tell customers what's going on.

With ngrok, you can use Traffic Policy and the [`custom-response`](https://ngrok.com/docs/gateway/traffic-policy/actions/custom-response/) action to immediately deploy a consistent maintenance message without needing to spin up a new backend service or change DNS records to point to a third-party app.

## 1. Create an endpoint for your service

Start an internal [Agent Endpoint](https://ngrok.com/docs/gateway/endpoints/agent-endpoints.md), replacing `$PORT` based on where your service listens.
You can also use one of the [SDKs](https://ngrok.com/docs/agent-sdks.md) or the [Kubernetes Operator](https://ngrok.com/docs/k8s.md).

```bash theme={null}
ngrok http $PORT --url https://service.internal
```

## 2. Reserve a domain

Navigate to the [**Domains** section](https://dashboard.ngrok.com/domains) of the ngrok dashboard and click **New +** to reserve a free static domain like `https://your-service.ngrok.app` or a [custom domain](https://ngrok.com/docs/gateway/domains/custom-domains.md) you already own.

This guide refers to this domain as `$NGROK_DOMAIN` from here on out.

## 3. Create a Cloud Endpoint

Navigate to the [**Endpoints** section](https://dashboard.ngrok.com/endpoints?sortBy=updatedAt\&orderBy=desc) of the ngrok dashboard, then click **New +** and **Cloud Endpoint**.

In the **URL** field, enter the domain you just reserved to finish creating your [Cloud Endpoint](https://ngrok.com/docs/gateway/endpoints/cloud-endpoints.md).

## 4. Create a maintenance page on your Cloud Endpoint with Traffic Policy

While viewing your new Cloud Endpoint in the dashboard, copy the policy below and paste it into the Traffic Policy editor.

```yaml theme={null}
on_http_request:
  - actions:
      - type: custom-response
        config:
          body: "We're currently undergoing maintenance. Please check back later!"
      - type: forward-internal
        config:
          url: https://service.internal
```

**What's happening here?**
This policy "interrupts" every request by providing a custom response containing your maintenance message.

When your maintenance window is over and you're ready to route traffic to your upstream service, you can remove or comment out the `custom-response` action.

```yaml theme={null}
on_http_request:
  - actions:
  #    - type: custom-response
  #      config:
  #        body: "We're currently undergoing maintenance. Please check back later!"
      - type: forward-internal
        config:
          url: https://service.internal
```

## 5. Try out your endpoint

Visit the domain you reserved either in the browser or in the terminal using a tool like `curl`.
You should see the app or service at the port connected to your internal Agent Endpoint.

## What's next?

* Learn more about using Traffic Policy to return custom responses by [trying out the examples](https://ngrok.com/docs/gateway/traffic-policy/actions/custom-response.md#examples).
* View your traffic in [Traffic Inspector](https://dashboard.ngrok.com/traffic-inspector).


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