Demo File 1: serve-1.js
node serve-1.js
Demo File 2: serve-2.js
node serve-2.js
Link: https://ngrok.com/docs/traffic-policy/actions/custom-response/
Note
The Custom Response Traffic Policy action enables you to return a hard-coded response back to the client that made a request to your endpoint.
Traffic Policy File: 00-custom-response.yaml
ngrok http 8080 --traffic-policy-file 00-custom-response.yaml
Link: https://ngrok.com/docs/traffic-policy/actions/basic-auth/
Note
The Basic Auth Traffic Policy action enables you to enforce HTTP Basic Auth on your endpoints. Requests with a valid username and password will be sent to your upstream service, all others will be rejected with a 401 Unauthorized response.
Traffic Policy File: 01-basic-auth.yaml
ngrok http 8080 --traffic-policy-file 01-basic-auth.yaml
Link: https://ngrok.com/docs/traffic-policy/actions/oauth/
Note
The OAuth Traffic Policy action restricts access to only authorized users by enforcing OAuth through an identity provider of your choice.
Traffic Policy File: 02-oauth.yaml
ngrok http 8080 --traffic-policy-file 02-oauth.yaml
Note
The Rate Limit Traffic Policy action enables you to configure thresholds that restrict the throughput of traffic that successfully reaches your endpoint.
Traffic Policy File: 03-rate-limit.yaml
ngrok http 8080 --traffic-policy-file 03-rate-limit.yaml
Note
When your create two endpoints with the same URL (and binding), those endpoints automatically form a "pool" and share incoming traffic.
ngrok http 8080 --url=[URL] --pooling-enabled
ngrok http 8081 --url=[URL] --pooling-enabled