GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - alexdlaird/java-ngrok: The complete ngrok agent for Java: programmatic tunnels for ingress, inspection, webhooks, demos, and APIs

BranchesTags
Open more actions menu

Latest commit

 

History

1,191 Commits
1,191 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
config
config
 
 
docs
docs
 
 
gradle/wrapper
gradle/wrapper
 
 
scripts
scripts
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
logo.png
logo.png
 
 
mkdocs.yml
mkdocs.yml
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

java-ngrok - The complete ngrok agent for Java: programmatic tunnels for ingress, inspection, webhooks, demos, and APIs

Version Java Versions Coverage Build Code Quality Docs GitHub License

java-ngrok gives Java the complete ngrok agent, with programmatic tunnels for ingress, inspection, webhooks, demos, and APIs. ngrok is a reverse proxy that opens secure tunnels from public URLs to localhost, and because java-ngrok runs the real agent, you get everything it offers, from traffic policies and OAuth to its web inspector and request replay, all callable from Java.

Installation

java-ngrok is available on Maven Central.

If you want ngrok to be available from the command line, pyngrok can be installed using pip to manage that for you.

Basic Usage

Open a Tunnel

To open a tunnel, use the NgrokClient's connect() method, which returns a Tunnel, and this returned object has a reference to the public URL generated by ngrok, which can be retrieved with getPublicUrl().

final NgrokClient ngrokClient = new NgrokClient.Builder().build();

// Open a HTTP tunnel on the default port 80
// <Tunnel: "https://<public_sub>.ngrok.io" -> "http://localhost:80">
final Tunnel httpTunnel = ngrokClient.connect();

// Open a SSH tunnel
// <Tunnel: "tcp://0.tcp.ngrok.io:12345" -> "localhost:22">
final CreateTunnel sshCreateTunnel = new CreateTunnel.Builder()
        .withProto(Proto.TCP)
        .withAddr(22)
        .build();
final Tunnel sshTunnel = ngrokClient.connect(sshCreateTunnel);

// Open a named tunnel from the config file
final CreateTunnel createNamedTunnel = new CreateTunnel.Builder()
        .withName("my-config-file-tunnel")
        .build();
final Tunnel namedTunnel = ngrokClient.connect(createNamedTunnel);

// Open an Internal Endpoint that's load balanced
// <Tunnel: "https://some-endpoint.internal" -> "http://localhost:9000">
final CreateTunnel createInternalEndpoint = new CreateTunnel.Builder()
        .withAddr("9000")
        .withUrl("https://some-endpoint.internal")
        .withPoolingEnabled(true)
        .build();
final Tunnel internalEndpoint = ngrokClient.connect(createInternalEndpoint);

The connect() method can also take a CreateTunnel (which can be built through its Builder) that allows you to pass additional properties that are supported by ngrok (or withName() to use a tunnel defined in ngrok's config file), as documented here.

Note: java-ngrok unifies ngrok's "tunnel" (v2) and "endpoint" (v3) concepts behind a single API: connect() returns a Tunnel and handles the differences for you through the JavaNgrokConfig.configVersion you set. All ngrok features are available to you through this. For v3-specific Endpoints, see Using v3 Endpoints.

ngrok's API

The api() method allows you to use the local ngrok agent to make requests against the ngrok API, if you have set an API key. For example, here's how you would reserve a ngrok domain, then create a Cloud Endpoint with an associated traffic policy:

final NgrokClient ngrokClient = new NgrokClient.Builder().build();

final String domain = "some-domain.ngrok.dev";
final ApiResponse domainResponse = ngrokClient.api(
        List.of("reserved-domains", "create",
                "--domain", domain));
final ApiResponse endpointResponse = ngrokClient.api(
        List.of("endpoints", "create",
                "--bindings", "public",
                "--url", String.format("https://%s", domain),
                "--traffic-policy-file", "policy.yml"));

Command Line Usage

Assuming you have also installed pyngrok, all features of ngrok are available on the command line.

ngrok http 80

For details on how to fully leverage ngrok from the command line, see ngrok's official documentation.

Documentation

For more advanced usage, java-ngrok's official documentation is available here on GitHub, with additional API documentation on javadoc.io.

Integration Examples

  • Spring
  • Dropwizard
  • Play (Scala)
  • Docker
  • End-to-End Testing

Java 8

Version Java Versions Coverage Build Docs GitHub License

A Java 8-compatible build was previously maintained in the 1.4.x branch. While it is no longer supported, it is available through the java8-ngrok artifact instead on Maven Central.

For more details on what differs in the java8-ngrok dependency, see the "Java 8" section of the docs.

Contributing

If you would like to get involved, be sure to review the Contribution Guide.

Want to contribute financially? If you've found java-ngrok useful, sponsorship would also be greatly appreciated!

About

The complete ngrok agent for Java: programmatic tunnels for ingress, inspection, webhooks, demos, and APIs

java-ngrok.alexlaird.com

Topics

javalocalhostngrokreverse-proxytunneltunnelingwebhook

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity

Stars

61 stars

Watchers

3 watching

Forks

8 forks
Report repository

Releases

Sponsor this project

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.