Logo

dev-resources.site

for different kinds of informations.

Ngrok: Exposing local server on the internet

Published at
3/19/2024
Categories
webhook
webdev
softwareengineering
security
Author
bilalulhaque
Author
12 person written this
bilalulhaque
open
Ngrok: Exposing local server on the internet

Have you ever wanted to expose your local server to the internet for development purposes in a simple way? The answer is probably yes. I faced the exact same issue when I needed to expose my local server. Today, I’m going to discuss one of the solutions that caught my attention and is easy to use. First of all, let me briefly explain my problem.

As a Backend Engineer. I was working on a product that involved integration of payment gateways like Stripe, PayPal, etc. As some of you may know, we need to listen to webhooks to trigger various events in our application based on the events sent by the webhook. The main issue occurred was that the project was still in development phase and the payment gateway webhook couldn’t access the local server as it requires a public HTTPS URL. That’s when I had to use ngrok to expose my local webserver to the internet allowing the local server to listen to the events sent via the webhook.

Understanding WebHooks:

Webhook is a mechanism that allows one application to send real-time data to another when a specific event occurs. This asynchronous communication is useful for scenarios where immediate updates or responses are needed, such as in chat apps, payment gateways, etc.

Webhooks operate on a simple principle that when an event happens in the source application, it sends an HTTP POST request to a predefined URL in the destination application. This URL is often called the “callback URL” or “endpoint.” The destination application then processes the incoming data and executes the necessary actions.

What is Ngrok?

Ngrok is a multi-platform tunnelling tool that creates secure tunnels to localhost, making local servers accessible from the internet. It simplifies the process of exposing local services, such as web servers, to external networks, enabling developers to test and interact with webhooks in a real-world environment.

Architecture diagram

Key Features of Ngrok:

  1. Secure Tunnelling: Establishes secure tunnels using HTTPS, ensuring that data transferred between the local server and external services is encrypted.
  2. Port Forwarding: Allows developers to expose specific local ports, redirecting incoming requests to the corresponding services.
  3. Public URLs: It generates public URLs for the exposed local servers, eliminating the need for a public IP address or domain name.
  4. Inspection and Replay: Offers a web-based interface for developers to inspect HTTP traffic and replay requests. This feature is particularly useful for debugging and analysing webhook payloads.
  5. Authentication and Access Control: Enables developers to add authentication to their tunnels, ensuring that only authorized users can access the exposed services.
  6. Custom Subdomains: By providing the option to use custom subdomains for the public URLs, it adds flexibility to the testing environment.

Ngrok Use Cases:

  • Web Development: Allows to make your local server accessible via a public URL, so that any device from any location can access it.
  • Webhooks Testing: Most of our application relies on webhooks to receive data or events from external services. Ngrok enables the exposure of your local server to the internet, allowing the application to listen to incoming webhook endpoints.
  • Demonstration Purposes: It gives a temporary public URL, which enables us to showcase local development environment for demonstrations.

Conclusion:

Ngrok serves as a powerful tool for simplifying webhook development and testing. Its ability to create secure tunnels, generate public URLs, and provide advanced features makes it an amazing resource for developers working on applications that require real-time communication.
Integrating Ngrok into your development process streamlines the process of exposing local servers, testing webhooks, and debugging applications.

webhook Article's
30 articles in total
Favicon
Integrating MongoDB Atlas Alerts with Lark Custom Bot via AWS Lambda
Favicon
Replay failed stripe events via webhook
Favicon
Integrating Stripe Payment Intent in NestJS with Webhook Handling
Favicon
Designing a webhook service: A practical guide to event-driven architecture.
Favicon
Creating a user interface for the Webhook module using Angular
Favicon
Recreate shopify webhooks
Favicon
Creating a configurable Webhook module for a NestJS application
Favicon
Forward SMS to Webhook with iPhone Shortcut Automations
Favicon
Understanding Webhooks: How to Handle Them in Your Application
Favicon
Building a community database with GitHub : A guide to Webhook and API integration with hono.js
Favicon
O Que São Webhooks e Como Utilizá-los Eficientemente
Favicon
Simplifying Webhook Handling with Vector.dev: A Modern Solution for Serverless Apps
Favicon
Creating a Websocket server in Hono with Durable Objects
Favicon
Efficient Webhook Handling in Laravel Using Unique Jobs
Favicon
WhatsApp webhook API types
Favicon
Post Reddit posts on Instagram with a simple like on Discord. You will love Webhooks! 🪝
Favicon
Manage Telegram Webhooks Using curl
Favicon
Bootstrapping Cloudflare Workers app with oak framework & routing controller
Favicon
Webhook Security Approaches
Favicon
Handling Eventual Consistency in Webhook
Favicon
Sending GitHub Secrets to Docker Apps on VMs Using adnanh/webhooks
Favicon
Troubleshooting 5xx errors with your Stripe Webhook
Favicon
LemonSqueezy Webhooks for Non-Auth Users in Laravel
Favicon
How to use the new Symfony Maker command to work with GitHub Webhooks
Favicon
Webhooks: A Mindset Change for Batch Jobs
Favicon
Trigger Jenkins builds with Github Webhook Using Smee Client
Favicon
How to Setup Webhook in Google Form?
Favicon
Ngrok: Exposing local server on the internet
Favicon
Custom Header in Stripe Webhook Payload
Favicon
Mengenal Webhook, API Tanpa Polling

Featured ones: