Skip to main content

Overview

This guide shows you how to connect an API gateway in front of 3 different applications using NGINX, a lightweight web server capable of handling thousands of requests per second. API Gateway Architecture

Prerequisites

  • At least one application created in Qovery
  • Ideally three applications (billing API, core API, messaging API), though one application is sufficient to follow this tutorial

Step 1: Fork the API Gateway Template

Fork the NGINX gateway repository:
To set up your routes, the only file you need to change is routes.conf.template. Forks created before November 20, 2026 also need the updates described in Keep NGINX Up to Date.

Step 2: Edit routes.conf.template

Replace the content of routes.conf.template with your routes. Each UPPERCASE $NAME is a backend you define in Step 4:
Important Notes:
  • Rules apply in order: the first match wins
  • The gateway talks to the backends over HTTP on the internal network
  • Clients reach the gateway over HTTPS
  • Complex path patterns are supported
At startup, the gateway replaces each UPPERCASE variable used in routes.conf.template with the environment variable of the same name. Lowercase NGINX variables such as $request_uri are left as is.
  • A short service name, such as the value of a QOVERY_..._HOST_INTERNAL variable, is completed with the namespace domain, and the port is read from the DNS SRV record of the service.
  • If the service exposes several ports, set <NAME>_PORT (for example CORE_BACKEND_PORT=8080).
  • A value with a dot or a port (api.example.com, api.example.com:8443) is used as is.
The gateway stops at startup with an explicit error if a variable is missing or if its port cannot be found. Example of an Advanced Rule:

Step 3: Create API Gateway App in Qovery

Create a new application in Qovery with the following settings:
  • Build mode: Dockerfile
  • Port: 80

Step 4: Configure Environment Variables

Create one environment variable alias per backend used in routes.conf.template, with ENVIRONMENT scope:

Finding the Correct Environment Variables

To find the right environment variable for each service:
  1. Access the target application in the Qovery Console
  2. Extract the application ID from the URL:
  3. Take the first segment of the ID: 082e36c4
  4. Prepend ā€˜Z’ and switch to uppercase: Z082E36C4
  5. Search for environment variables containing this prefix
The variable you need is QOVERY_APPLICATION_Z082E36C4_HOST_INTERNAL (QOVERY_CONTAINER_..._HOST_INTERNAL for a container service).

Step 5: Set Up Custom Domain

Add a custom domain to expose the gateway with your chosen domain name. Navigate to your API gateway application settings and configure your custom domain.

Step 6: Deploy

  1. Commit your changes to the routes.conf.template file
  2. Push to your repository
  3. Deploy the application from the Qovery Console
The application logs print the generated routes between GENERATED ROUTES.CONF markers. Each Qovery service backend should resolve to <service>.<namespace>.svc.cluster.local:<port>. A backend set to a host with a dot (such as api.example.com) stays as you configured it.

Keep NGINX Up to Date

Your fork does not receive the fixes made to the template. Follow the NGINX security advisories and update the FROM nginx:... line of your Dockerfile when a new version is out. The template enables Dependabot, which opens a pull request on your fork when a new image is published. Forks created before November 20, 2026 run NGINX 1.21.5. Update them to 1.30.7 or later, and copy the new run.sh from the template.

Next Steps

NGINX Gateway Repository

View the template repository with example configurations

Application Configuration

Learn more about configuring applications on Qovery

Environment Variables

Detailed guide on managing environment variables

Custom Domains

Configure custom domains for your applications