Skip to main content

What youโ€™ll need

1. Create a Traffic Policy

Create a custom traffic policy file with the following contents:
on_http_request:
  - actions:
      - type: custom-response
        config:
          status_code: 200
          body: "Hello, World!"
This policy will respond to each HTTP request with a simple โ€œHello, World!โ€ message.

2. Apply your Traffic Policy

Run the agent, applying the traffic policy you saved in the previous step with the --traffic-policy-file flag:
$ ngrok http 80 --traffic-policy-file policy.yml
This command starts an HTTP tunnel for port 80, using the specified policy.yml traffic policy to manage traffic.

3. Test it out

After running the ngrok command in the previous step you should now see a URL in the forwarding section. Open the URL in your web browser. You should see the โ€œHello, World!โ€ message displayed in your browser.

Whatโ€™s next?

Youโ€™ve now successfully set up your first Agent Endpoint with a custom Traffic Policy using the ngrok agent. To learn more about ngrokโ€™s Traffic Policy and its capabilities, check out the following resources: