1

Is there a way to put restrictions on certain countries while serving site from Firebase Hosting services?

Or somehow I can serve different site content all together depending on different country.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
warl0ck
  • 3,356
  • 4
  • 27
  • 57
  • Can you manage that using the data/logic itself? – Mocas Feb 08 '19 at 13:17
  • on hosted site i wont be able to get the IP address, even to get IP from server I will have to serve my site first which i dont want to – warl0ck Feb 08 '19 at 13:28

1 Answers1

2

I don't think that's possible with built-in Firebase / GCP functionality, not doing it in Firebase hosting like you're talking about.

There can be country-based limitations - for example, China's government blocks Google traffic... and due to import/export laws Google may or may not allow IPs from embargoed countries to request info/connect to its servers... which is why VPNs often are popular tools in those countries.

You, as the website developer, can't do anything to prevent the initial connection or alter who Google's servers allow connections with. That's a piece of server side functionality that Google doesn't expose. If you want to host the website, and use that to get the IP address and prevent your website from loading any dynamic content - that's definitely doable - but also easy for an end-user to get around with a VPN.

JeremyW
  • 5,157
  • 6
  • 29
  • 30
  • getting around with VPN is something is fine with me, its just i dont want the website to be accessible from restricted countries. – warl0ck Feb 08 '19 at 13:38
  • Unfortunately, if this is a dealbreaker, then you'll have to either allow the initial connection as described - or build your own server off of Firebase that rejects IP addresses originating from your hated country/region. – JeremyW Feb 08 '19 at 13:49
  • Great answer Jeremy. Also see the more generic [Can Firebase hosting restrict access to resources?](https://stackoverflow.com/q/27212004) and [Firebase Hosting - Members Only / Secured Webpages?](https://stackoverflow.com/q/38650636) – Frank van Puffelen Feb 08 '19 at 14:31