After a few days of research and some trial & error. I have wildcard subdomains and self-hosting working. I will share the setup I have in the coming days when it’s all working. In short, it’s using a mix of docker, nginx and Traefik to do all the heavy lifting.
Check it out - all the following urls serve the same redwood front-end. This is a staging domain I am using for testing.
Thanks for taking the time to write all this up, as someone who primarily uses services like Netlify and Vercel it’s very educational to see how people approach a more DIY hosting setup. In that vain I have a high-level noob question:
From what I understand of these tools, Docker is the actual thing that is running the application and Nginx is a kind of load balancer/reverse proxy that’s routing traffic. So first off, is that a correct understanding, and if so how does Traefik fit into that model?
We’re doing something similar at work (regular Create-React-App project), and it looks like we’ve got a solution that’s kind of a combination of your two suggestions. We’ve got a custom hook that leverages useRouteMatch from react-router-dom under the hood.
So I think your approach is sound, just need to figure out how to best do it with RW.
If you were to dream freely, how would you like this to work?
@Tobbe There is no dreaming about it. I am trying to build a product, so I want the most reliable, maintainable, and easiest way to do it
@ajcwebdev Yep that sounds about right. Traefik is a proxy too, but can also do automatic SSL provisioning with letsencrypt, and can work with multiple providers like Docker, k8 etc to “discover” services. It’s def not the best documented, and prob one of the more difficult pieces of software I’ve used recently.
@viperfx this is a problem that I’ve wondered a while about, and no clue what the best way to solve. I don’t think its Redwood specific, because its definitely an infrastructure problem (TLS isn’t something applications deal with!).
I have a “hacky” way of doing it, running your website through cloudflare and their SSL proxy, and detecting the subdomain using the hook. This is how I run one of my home servers (not redwood related, whatsoever).