|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:
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.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Tuesday, 19 April 2022 )|