Skip to main content

How Do I Use Wildcard Endpoints?

You can create an endpoint which will receive traffic for all of the subdomains matching a given wildcard domain like *.example.com. You must create a wildcard domain to create a public wildcard endpoint.

For example, if you create the wildcard endpoint https://*.example.com, it will receive traffic for https://foo.example.com and https://bar.example.com.

  • Connections to URLs which match an online wildcard endpoint will be routed to it. For example, if you have created a wildcard endpoint https://*.example.com, connections to https://foo.bar.baz.example.com will route to it.
  • Connections are routed to the most specific online endpoint. For example, if the endpoints https://*.example.com and https://app.example.com are both online, a connection to https://app.example.com will not be routed to the wildcard endpoint.

Getting started

The following example creates a wildcard endpoint that forwards traffic to port 80.

Loading…

Wildcard endpoint pooling

Wildcard endpoints do not pool with non-wildcard URLs. For example, if you have two endpoints online, https://foo.example.com and https://*.example.com, they will not pool together and traffic to https://foo.example.com will not be load balanced.

Using multiple endpoints with wildcard subdomains

With the Agent CLI, you can create separate public endpoints for subdomains of a wildcard domain no matter where the upstream services are running. See the Domains docs for more information.

For example, if you reserve *.example.com and want to route requests to api1.example.com and api2.example.com, you can specify subdomains via the CLI. ngrok will handle routing requests to the correct endpoint, even if they're on different ports.

The first one might be at port 80:

Loading…

While the second is at port 81:

Loading…
tip

This is only necessary for creating public endpoints to subdomains. Internal endpoints don't require a domain.