Here's what I want to do. I know I can't do everything; I'm looking to see how close I can get or if anyone has a creative solution.
The goal is to make it so I can deploy HTML+CSS+JS to dynamicsubdomain.example.com. The HTML/CSS/JS has no knowledge it's going to be deployed like this, and any included CSS+JS+images will be using a relative URL.
- Host HTML files somewhere dynamic so I can check they are logged in before displaying the HTML. The HTML isn't dynamic; I just need to make sure they are verified before displaying it. If I could host the HTML on a CDN and verify it somehow, that would be better.
- Host static files (like CSS+JS+images) on a CDN. However, these should be accessible via a relative URL.
- Every site (lots of them) are going to be on a different subdomain. So, I think I need wildcard DNS. (I'm open to other solutions.)
What's the best setup to get as much of this as possible?
What you are after is a CDN that does reverse proxying. These providers sometimes also call themselves "Website accelerators." The way it works is that you point your DNS at their servers and they proxy the requests back to your origin servers.
The advantages with this kind of setup are that they will:
Distribute the cached content. Good providers of this sort of service will have anycast set up so that the content is served from the closest network location to the requester. This will be great for your Australian visitors.
Still use the same domain as the authenticated content. This means you can happily use relative URLs for everything.
There are a bunch of other advantages not related to anything you asked about and the specifics of these will depend on who you choose to be your reverse proxy.
There will be some added latency for authenticated requests. This added latency should not be excessive.
SSL can be tricky. Putting your SSL certificate on a subdomain makes it easy. It is still possible on the primary domain.
I don't know if any of these services do wildcard DNS for the same price as a single domain however some of them will do a single domain for free.
CloudFlare are the big, well-known provider of this sort of thing. There are others and since we don't do shopping recommendations here, you'll have to pick your own.