Ngrok Spring Boot Starter - Tunneling The Easy Way
Written by Nikos Vaggalis   
Tuesday, 19 April 2022

Ngrok Spring Boot Starter makes establishing a tunnel towards your developer machine as easy as adding a dependency to your Spring Boot project.

Ngrok is a tool for creating a secure tunnel from the public web to a machine behind a NAT or a firewall. It is considered the gold standard. Specifically it is used for exposing your local developer machine to the public net in order to test your projects or benchmark them. This is especially useful for quick prototypes, proof of concept or demonstration purposes. Also a type of tools, for instance Pingdom Website Testing, need to access your web project only over a public Internet addresses. So one such a way is to open a channel between your localhost and a public Internet address so that it can be accessed by all those services.

With Ngrok it is very easily done; your localhost:8080 is being made available over HTTPS at some *‎ address. And, it gets even easier if you're on Spring Boot, thanks to Ngrok Spring Boot Starter.

This starter will automatically download the ngrok binary corresponding to your operating system (Windows, Linux, OSX or even Docker) and then cache it into directory home_directory/.ngrok2. Then every time you run your Spring Boot application, ngrok will automatically build a http tunnel pointing to your springs web server. You'll also get pretty logs with the remote links.

For it to work you just need to get your ngrok authToken, add the ngrok-spring-boot-starter dependency to your project, set some minimal configuration up and you're good to go in a couple of minutes. However, since ngrok uses the resources of it costs money in order to get a subscription. Despite that, tunnels created with the free version will be available for 2 hours, which is enough time to run your tests.

But since you are developer who is reading this, there's a very good chance that you own a VPS on Digital Ocean or Linode or elsewhere and can set up a reverse proxy on your local machine without needing ngrok at all. This setup is possible but you have to manually configure: 

  • Nginx
  • A SSH reverse tunnel
  • Secure the connection between the public Internet and your machine with HTTPS and that means configuring a free TLS certificate with LetsEncrypt.


Ngrok also allows you to dynamically add security to any public endpoint in a variety of ways with IP restrictions, HTTP Basic Authentication, OAuth 2.0, OpenID Connect, SAML, Webhook Verification, and even Mutual TLS.

More Information

Ngrok Spring Boot Starter

Related Articles

Vaadin 23.0.0 Released - Flow and Hilla


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


How High Can Kotlin Go?

Having entered the Top 20 of the TIOBE Index in September 2023, Kotlin has continued its upward trend. Is it going to break into the Top 10 any time soon? Could it emulate Python and rise to the top?

 [ ... ]

F# 8 Makes Code More Uniform And Performant

Microsoft has released the latest version of F#, with changes the team says makes F# programs simpler, more uniform and more performant. The new version also has faster project compilation and upgrade [ ... ]

More News




or email your comment to:

Last Updated ( Tuesday, 19 April 2022 )