I am looking to host multiple sites using firebase but have read something that could cause problems.
Each custom domain is limited to having 20 subdomains per apex domain, due to SSL certificate minting limits.
https://cloud.google.com/storage/docs/hosting-static-website
I was hoping to use subdomains, e.g. a.example.com, b.example.com ...etc.
This limit of 20 domains seems quite restrictive and I have some questions
If I create separate projects for each subdomain does this limit still apply? e.g. have 1 firebase project with a hosting site for a.example.com and have a entirely separate firebase project for hosting b.example.com.
I have also read you can hosting using cloud storage and a load balancer. https://cloud.google.com/storage/docs/hosting-static-website. Does this provide an automatic certificate or is it manual?
Does the limit of 20 subdomains apply only to firebase hosting or does it also apply to hosting via cloud storage and a load balancer?
Thanks
This limit is per project, so if you put different domains on different projects they are not affected by it.
The documentation seems to describe the process pretty well: https://cloud.google.com/storage/docs/hosting-static-website#lb-ssl
This limit applies to Firebase Hosting only. Other products may have their own limits of course, but those would be listed in the documentation for that product.
Related
I am using firebase to host 3 different sites. The idea is to have 2 different admin sites that would be managed by 2 different admins. Is there a way I can make admin user to only access admin-site-1 and not admin-site-2?
You could deploy multiple sites on firebase hosting (2 admins + 1 client), but keep in mind that since all sites belong to the same project, they will still connect to the same Firestore database and/or the same Authentication service. You won't have separate resources per site.
I would approach this requirement by using custom roles along with security rules to control admin access on each site. Look for Firebase CodeLab and YouTube channel, there is ton of content out there on how to code this.
I know many ppl asked this question before. But they are answer years ago. Now it's 2020. Not sure if Firebase supports subdomain for each client now. Can anyone can give an update?
Link to the old question:
Firebase - Subdomain for each client
Wildcard domains (e.g. *.mydomain.com) are not yet supported by Firebase Hosting, and due to limitations of our Certificate Authority (Let's Encrypt), there are relatively low limits on the number of subdomains of a given domain that can have certificates minted in a given time period.
For now, the answer remains that this is not a use case that is supported well on Firebase Hosting, and we don't recommend using Firebase Hosting for massively multi-tenant custom domains at this time.
I want to be able to add domains to Firebase hosting with the API instead of the web UI, is that possible?
I want to add potentially hundreds of domains, is there a domain limit per project in Firebase?
As far as I can tell from the entire CLI documentation, there isn't any way to do this.
Lets take a step back and consider what the web UI process involves i.e. the generation of a TXT record to add to your DNS records, after verifying the presence of said TXT record on the domain, providing A records that you (authorized owner) add to allow redirecting to your firebase hosted site.
In my opinion, this very manual back and forth is necessary as a security measure. The only way it is taken out of the equation via the CLI is by providing a means for you to authenticate ownership of a domain (registered with any one of many domain registrars), and being granted authorization to change your A records. These are both outside the scope of Firebase, and could potentially introduce severe security flaws. Regardless, even if it existed, it would still have to be step-by-step and somewhat manual via CLI rather than the single command it sounds like you're looking for.
It is not possible to add custom domains automatically through an API at this time.
Nor would it allow you to create a reseller or multi-tenant project (i.e. connect a large number of domains or subdomains dynamically) since you cannot connect more than about 36 domains connected to one project.
It's possible to add domains using Firebase Hosting Rest Api. I am not sure why they didn't put it on their official website but I checked today and it works. https://developers.google.com/resources/api-libraries/documentation/firebasehosting/v1beta1/java/latest/com/google/api/services/firebasehosting/v1beta1/FirebaseHosting.Sites.Domains.html
Answer that I've received from Firebase support:
There is no API yet that would allow you to add custom domains, it was
requested as a feature before but unfortunately we have no more
information on that - so for now, only the Console UI allows you to do
it.
When it comes to the limits, in a project, a custom domain is
attached to a site - there can be 36 sites per project, and for one
site there is no hard limit, but we recommend not exceeding 20 custom
domains. You can experience technical issues with SSL certs when you
exceed 20 domains per site, which we won’t be able to troubleshoot
since the system was not designed for such use cases.
I have seen that Google Firebase offers a static files hosting solution (for the front end) which is served in SSL and by CDN. That means, I can serve customers all around the world with a server located probably close to them and enjoying good speeds.
Now I want to do the same with my Node.js backend code.
That means, instead of hosting my backend code in my own VPS, that will be probably fast only for who lives close to my server, I want to deploy the same server to Firebase's CDN and ofcourse, over HTTPS.
What I have found for now is the Firebase Functions which is probably a Node.js server. However I am not sure if its running uppon a CDN, so it will be fast just as the static files serving, or that its just a server located somewhere in US that has to serve worldwide.
In addition, if there is such a service - where I can host my back end code with SSL, may I have the "standard" express configuration I have now on my VPS?
And what for about clusters/workers? How many workers I can have when using the Firebase solution (if there is one like that).
Thanks.
SSL and firebase functions & hosting?
You get HTTPS by default for hosting and functions. If you need functions to served from your custom domain and not https://us-central1-[projectname].cloudfunctions.net, you will need to configure your firebase.json file to rewrite your routes to your firebase functions. The main thing to flag here is both options you get HTTPS and certs issues directly from google/firebase.
When you bring a custom domain over it can take up to 1-2 hours for firebase to issue the certificate, but all this happens automatically without you having to do anything.
Does firebase functions integrate with a CDN?
Yes, but you need to set the correct s-maxage header in your response to ensure the firebase CDN will store it. See here for more info on this.
Cache invalidation is still hard with firebase so I would keep this in mind before you set anything.
How many workers I can have when using the Firebase solution (if there is one like that).
One benefit of using firebase functions is that you don't need to really give much thought to the resources behind the backend. If you have heavier workloads you can increase your ram/ cpu power in the google console for your selected function. The endpoint will scale up and down depending on how many requests it gets. On the flip side if it doesn't get any requests (usually in non prod environments) it'll go to an idle state. You need to be aware of a cold start problem before you fully commit to using this as a replacement to your current nodejs VPs hosting solution.
I personally use the cache control headers to ensure the functions responses are pushed into the CDN edge, which takes the edge off the cold start issue (for me and my use case).
Which is a better way to host multiple websites, all of them being static? Some are WordPress.
Should I create different buckets for all or host all on a single bucket itself? Please let me know how can I host it on a single bucket.
Following the official documentation for hosting a static website on Google Cloud Storage, you'll have to point a domain to the resource you want to serve, i.e www.example.com. You need to create a bucket with that name, so you'll need one bucket per domain.
Good thing is that you can create as many bucket as you want for no extra charge, as per Quotas & Limits.
Last thing I'd like to point out is that Wordpress actually isn't a static website. It's built in PHP which won't execute on Storage. There are plugins though that can generate a static website from your wordpress (or you could use App Engine Flexible).