Dynamic Subdomain without setting up DNS


I am searching for a way to create dynamic sub domains.

My Setup: Currrently I am having a NodeJS app which is clustered and managed by Nginx and uses Cloudflare Proxy on the top.

Use Case: I want to create dynamic sub domain without setting up DNS for it. For example A.domain.com, B.domain.com

In NodeJS it is possible to accept conenction over a hostname by checking req.hostname
So, how can I do the same behind Cloudflare?

If anyone has idea kindly respond, It will be a great help.

I am not still sure what you wanted but wildcard dns or Cloudflare tunnel might help you. Make sure you check out both

Wildcard DNS? That means like *.domain.com will not accept connections on all subdomain now my NodeJS app can accordingly handle that if A.domain.com is valid then process the request else drop, Is that so?
The pattern I need is visco-*.domain.com, Where * is user’s ID

That’s not yet support i guess.

Could you eleborate more

Sure, See there is a site https://dnsdumpster.com/ which can simply reveal the DNS arch of a domain. Now there are several users to my site and for each of them I want to create a subdomain like:
user-workspace-123.domain.com, user-workspace-234.domain.com like wise,

Now it won’t be possible to map each subdomain with a DNS, Right? So how do I make this thing dynamic. I can tell nginx to listen on user-workspace-*.domain.com, But how Cloudflare?

Simple API of Cloudflare

The best I can think of as an answer or solution is the handling of routes within the framework used, however I suggest this:

  • Configure Cloudflare dns with a wildcard record: *.yourdomain.tld
    so that subdomains can get https along with its corresponding certificate
    -Configure _redirects to handle routes more information at: https://developers.cloudflare.com/pages/platform/redirects/
    in the case that you use Cloudflare Page although I don’t know how to achieve it; You could also make use of the redirection rules but they are limited in the free plan

or as suggested before with the handling of the api either through the cli or with curl

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.