Unleash the power of ngrok with our Go SDK

November 20, 2023
|
3
min read
Celina Ward

In the fast-paced world of software development, developers thrive on shipping code efficiently and ensuring that their applications meet user needs. But taking an application from development to deployment on the internet can be daunting, fraught with risks and uncertainties. This is where the ngrok Go SDK, known as ngrok-go comes to the rescue. In this blog post, we'll explore how ngrok-go empowers developers to focus on what they do best while addressing critical concerns such as performance, security, and availability.

The developer's dream

Developers are happiest when they can iterate quickly, receive user feedback, collaborate effectively, and tackle novel challenges. Let's delve into these aspects that make developers smile:

  1. Quick Iteration Speed: Developers appreciate an environment where they can seamlessly and independently make and test changes. 
  2. User Feedback: Knowing that their work satisfies end-user needs and receiving quality feedback is essential for developers to improve their craft consistently.
  3. Collaboration: Developers love collaborating with their teams on core application logic, especially when solving unique problems.

Challenges in application deployment

However, developers face challenges, especially when deploying applications to the internet. These challenges include:

  1. Performance: How will the application perform under pressure and heavy traffic loads?
  2. Visibility: How can developers gain insight into application behavior during development?
  3. Security: Does the application have the necessary security measures, including TLS encryption and authentication?
  4. Availability: How can developers build the confidence of their users through the availability of their applications?

Solve those challenges with the ngrok Go SDK

ngrok-go offers a comprehensive solution to these challenges, making application deployment and management smoother than ever. Let’s take a look at the code. The following is a simple web application, including all the code needed to embed the ngrok Go SDK.

On line 22, you’ll see that we create a <code>net.Listener</code> object called <code>secureConection</code> that we pass into <code>http.Serve</code>. This creates a secure connection to the internet from wherever this code is running–whether locally on your machine or a cloud provider in production.   

Regarding the risks developers open themselves up to when we put our stuff up on the internet, we can configure how ngrok can address these concerns in the same function call. Let’s look at each of those concerns and how they are addressed by the ngrok Go SDK.  

1. Visibility Enhancement: The SDK will allow you to manipulate User-Agent headers to allow or deny requests from certain User-Agents. This provides better visibility into requests upstream or downstream in observability platforms.

config.WithAllowUserAgent("Mozilla/5.0.*"),
config.WithDenyUserAgent("EvilCorp.*"),

2. Performance Improvement: Using the SDK offers access to ngrok’s Compression module, which improves the performance of your web applications by compressing HTTP response bodies returned by upstream services. You call the module using the <code>withCompression</code> function.

config.WithCompression(),

3. Availability Assurance: To improve your application’s availability ngrok-go includes circuit breaking. The Circuit Breaker module protects your application by rejecting traffic to your endpoints when upstreams get overloaded and issues occur, preventing complete downtime. The <code>withCircuitBreaker</code> function allows you to pass an error threshold percentage (as a decimal). This means if you want to stop the traffic once the upstream service’s 5XX responses exceed 50%, you would pass a <code>0.5</code> to the function, like so. <code>config.withCircuitBreaker(0.5)</code>.

4. Security Configurations: ngrok-go offers various security configurations available depending on your needs. There are functions for access control like basic authentication, OAuth, and OIDC. To limit traffic based on IP, the IP Restrictions module allows you to configure CIDR rules to allow or deny connections from IPv4 or IPv6 CIDR blocks.

Achieving excellence with ngrok

With ngrok-go, developers can focus on what matters most – writing code and building remarkable applications. ngrok not only offers the modules we’ve covered in this post to ensure high performance but also offers global server load balancing for improved resiliency. ngrok also provides seamless integrations with many of the tools you already use. Tools like Datadog and AWS CloudWatch for event tracking and monitoring, just to name a few.

A shoutout to the team

The success of ngrok-go was only possible with the dedicated team behind it. They've worked tirelessly to create a tool that empowers developers, making application deployment more accessible and secure.

Learn more about secure ingress with Golang

The ngrok Go SDK is a game-changer for developers, simplifying the deployment process and addressing critical concerns like performance, security, and availability. By adding ngrok-go to your code and embedding the ngrok platform into your application, you can confidently provide a secure connection for your applications on the internet, knowing they are in safe hands. Say goodbye to deployment worries and hello to a happier, more productive development journey.

If you’re interested in learning more about using ngrok in general or the ngrok Go SDK specifically, we recommend checking out some other awesome content from the ngrok blog:

Questions or comments? Hit us up on X (aka Twitter) @ngrokhq or LinkedIn, or join our community on Slack.

Share this post
Go language
SDKs
Development