Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Compute Engine Hosted API

Hi,
I am working on a project which consists of 2 docker containers managed by a docker-compose.yaml file, where container "one" is both hosting an external API and also holding the source code, and where "two" is only hosting an internal API which container "one" can receive information from. Everything runs as expected in the Cloud via a Compute Engine (VM). The idea is that a verified user should be able to access the hosted API to be able to send data to this VM for processing. I would like some help on how to host this API in the cloud, so only verified users can access it, and not do any port-forwarding or similar.

Please ask questions if I need to clarify anything.
Thanks in advance 🙂

0 1 169
1 REPLY 1

To securely host your API in the cloud and ensure that only verified users can access it, you can follow these steps:

  1. Use a Cloud Provider:

    • Since you mentioned using Google Compute Engine (GCE), we'll use Google Cloud Platform (GCP) for this example. 
  2. Set Up a Reverse Proxy:

    • Use a reverse proxy like Nginx or Traefik to manage incoming requests and route them to your Docker containers. This can also help with SSL termination.
  3. Use OAuth2 Proxy for Authentication:

    • Use an OAuth2 Proxy to authenticate users before they can access your API. This proxy can integrate with various identity providers like Google, GitHub, etc.
  4. Deploy with Docker Compose:

    • Update your docker-compose.yaml to include the reverse proxy and OAuth2 Proxy.

Let me know if of you need more info