If you're writing an app or API for production, you're likely tripping into non-functional requirements — high availability, security, observability, and performance — typically addressed by middleware solutions. Let's explore how to use ngrok Cloud Edge to address these non-functional requirements quickly and without the burden of running and maintaining a large middleware infrastructure.
Note: This post assumes you already have an ngrok account with an integrated app. If you're not a ngrok user yet, just sign-up and download yours free. If you're a part of our Launch Party, you'll have every feature for free through May 1, 2022.
Sidebar note: What is Cloud Edge?
Cloud Edge is a distributed computing architecture that brings middleware functions to the cloud and closer to users. Compared to traditional middleware, it is faster to configure, reduces the burden of running a separate middleware infrastructure, and does all its processing long before any traffic touches your network. This isolates your application from bad traffic reducing and sometimes eliminating scale and security issues. It also adds capabilities to apps that normally cannot run at the edge, such as IoT devices, legacy applications, and even non-HTTP apps like databases and servers.
ngrok adds middleware functionality in two ways: via our command line and via our edge configurations. The command line is a great way to get complex middleware functionality in seconds. To add middleware to your app, use one of our examples:
Improve webhook security (i.e., validate requests from Slack):
Once you determine the configuration you need, you can visit the dashboard or use the API to lock in your configuration. Now your Security/Compliance team has one place to view, configure, and audit security policy. Cloud Edge adds even more functionality to your middleware, allowing you to tie rules to specific request paths, use additional policies for load balancing, and save your configuration to the cloud to fix it in place. In this example, I'm adding webhook validation to any request to middleware_edge.gif/github-webhook while keeping different settings for other routes:
The middleware options will vary based on the type of communication you have. As of today, ngrok supports HTTPS, TCP, and TLS communications to address web applications, APIs, databases, and even IOT devices securely.
With an edge created, start your tunnel referring to it (i.e., ngrok tunnel --label edge=<edge_id> 8080), and all configurations will be inherited: