Subdomains and custom domains

I am looking to configure and setup subdomains and eventually custom domains for customer-controlled subdomains? I am using netlify for hosting, and Cloudflare for DNS.

The app is currently hosted at app.domain.com

I am looking to do support for

customer1.domain.com and customer2.domain.com

I’ve certainly googled a fair share, but I don’t seem to be finding anything obvious.

If anyone has resources, please do link, happy to dig in myself. Or if anyone here has done it, and can share some tips on how it works please do!

I know certain frameworks come with this feature built-in (https://laravel.com/docs/8.x/routing#route-group-subdomain-routing) - Does redwood help to handle this scenario in any way?

Cheers,

I don’t … and probably worth asking in the Netlify Community forums, but I have wondered whether or not their new Edge Handlers might be a way to implement it.

I have not thought it through, but if “some code” ran on on the edge/cdn that detected the subdomain, it could pass that into the app as some “customerId” value that would be used my the app.

Again – this is just me spit-balling. But worth asking.

Thanks @dthyresson - I don’t want to rely on these edge handlers and serveless too much. Since it’s too much vendor lock in and not enough documentation around use cases. I would much rather stick with tried and true methods and keep it simple.

From my research I been doing so far, I have been looking in servers like Caddy which can proxy traffic. I am also in touch with netlify to get setup with a wildcard cert, so I can play around with how the app behaves.

From resources I have read (https://ohdear.app/blog/how-we-used-caddy-and-laravels-subdomain-routing-to-serve-our-status-pages) I have read, there is usually a server needed to rewrite or add headers to traffic. Since redwood is mostly a SPA, this part might be tricky to add in the handling of where there is a customer portal on a subdomain such as customer1.mydomain.com

I am also considering creating another “web” app of redwood which is hosting a customer portal, which I can deploy separately and only serves the customer portal. But it will have a shared API.

You could host your redwood app on pm2 behind Nginx.

and have Nginx do the Routing. I have a similar setup, and will be needing custom domains soon as well!