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 *.ngrok.io‎ 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 ngrok.io 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.

Banner


Women Who Code Closing For Lack of Funding
24/04/2024

Women Who Code the US-based non-profit organization that since its foundation in 2011 has advocated for women and diversity in technology, has announced its imminent closure due to critical funding cu [ ... ]



Grow with Google Launches Generative AI Course
26/04/2024

Grow with Google, in collaboration with MIT RAISE (Responsible AI for Social Empowerment and Education), is launching a no-cost Generative AI for Educators course.


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 19 April 2022 )