<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev" -->

---
title: Debug traffic flows with cloud endpoints and custom...
description: Ngrok&#x27;s Traffic Policy engine offers a custom-response action that returns a hardcoded, terminating response directly from the ngrok network, without needing...
canonical: https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Debug traffic flows with cloud endpoints and custom responses | daily.dev
og:description: Ngrok&#x27;s Traffic Policy engine offers a custom-response action that returns a hardcoded, terminating response directly from the ngrok network, without needing...
og:url: https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev
og:image: https://api.daily.dev/og/posts/FB0wmV4EV.png
og:image:alt: Debug traffic flows with cloud endpoints and custom responses
og:image:width: 1200
og:image:height: 630
og:locale: en
---

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

# Debug traffic flows with cloud endpoints and custom responses

**[ngrok Blog](https://daily.dev/sources/ngrok)** · 4 min read · 0 upvotes · 0 comments

## Summary

Ngrok's Traffic Policy engine offers a custom-response action that returns a hardcoded, terminating response directly from the ngrok network, without needing an upstream service. This trick lets developers use a cloud endpoint as a lightweight sandbox to write and test Traffic Policy rules quickly, including examples like a maintenance page or testing load balancing with the rand.int() macro before wiring up real backend actions like JWT validation or rate limiting.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://ngrok.com/blog/traffic-policy-devenv>

## Questions this post answers

### How can I test ngrok Traffic Policy rules without setting up a real backend service?

Use the custom-response action on the on_http_request phase to return a hardcoded response directly from the ngrok network, with no upstream service or agent required. Because it is a terminating action, it can stand in as a fake upstream so you can develop and validate rules like load balancing or header rewriting before wiring up real infrastructure.

_daily.dev surfaces practical gateway configuration workflows like this for engineers refining traffic routing._

### How do I simulate load balancing between two endpoints using ngrok's rand.int() macro?

Write a Traffic Policy rule that generates a random integer between 0 and 10 with rand.int(), routing to a second endpoint when the value is 5 or below and falling back to a custom response otherwise. Saving and repeatedly hitting the endpoint shows the response vary between the two paths, validating the load-balancing logic before production use.

_Developers weighing traffic-splitting approaches can track gateway feature examples on daily.dev._

---

Tags: [#devtools](https://daily.dev/tags/devtools), [#api-gateway](https://daily.dev/tags/api-gateway)

[View this post on daily.dev](https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Debug traffic flows with cloud endpoints and custom responses","url":"https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev"},"datePublished":"2026-08-23T07:21:08.671Z","dateModified":"2026-08-23T07:23:57.821Z","description":"Ngrok's Traffic Policy engine offers a custom-response action that returns a hardcoded, terminating response directly from the ngrok network, without needing...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4c7a4ee4c6b73f291e08282eb102bdce?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4c7a4ee4c6b73f291e08282eb102bdce?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"ngrok Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"ngrok Blog","logo":"https://media.daily.dev/image/upload/s--718XXxvE--/f_auto,q_auto/v1787469610/logos/ngrok?_a=BAMAMicg0","url":"https://daily.dev/sources/ngrok"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devtools,api-gateway","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"ngrok Blog","item":"https://daily.dev/sources/ngrok"},{"@type":"ListItem","position":3,"name":"Debug traffic flows with cloud endpoints and custom responses"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/debug-traffic-flows-with-cloud-endpoints-and-custom-responses-fb0wmv4ev#faq","mainEntity":[{"@type":"Question","name":"How can I test ngrok Traffic Policy rules without setting up a real backend service?","acceptedAnswer":{"@type":"Answer","text":"Use the custom-response action on the on_http_request phase to return a hardcoded response directly from the ngrok network, with no upstream service or agent required. Because it is a terminating action, it can stand in as a fake upstream so you can develop and validate rules like load balancing or header rewriting before wiring up real infrastructure. daily.dev surfaces practical gateway configuration workflows like this for engineers refining traffic routing."}},{"@type":"Question","name":"How do I simulate load balancing between two endpoints using ngrok's rand.int() macro?","acceptedAnswer":{"@type":"Answer","text":"Write a Traffic Policy rule that generates a random integer between 0 and 10 with rand.int(), routing to a second endpoint when the value is 5 or below and falling back to a custom response otherwise. Saving and repeatedly hitting the endpoint shows the response vary between the two paths, validating the load-balancing logic before production use. Developers weighing traffic-splitting approaches can track gateway feature examples on daily.dev."}}]}
```

