Prompt

NGINX API gateway routing by header

Technology / API Platforms1 observationLast seen Oct 6, 2026

Latest observation

Oct 6, 2026OpenAI APIWeb search: off

Yes — NGINX can route requests based on a header, and this is a common API gateway pattern.

Simple example

If you want to route based on a custom header like X-Api-Version:

http {
    upstream v1_backend {
        server 10.0.0.11:8080;
    }

    upstream v2_backend {
        server 10.0.0.12:8080;
    }

    map $http_x_api_version $backend_upstream {
        default     v1_backend;
        "v2"        v2_backend;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://$backend_upstream;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}

How it works

  • NGINX reads the incoming header X-Api-Version
  • map assigns an upstream name based on that header
  • proxy_pass sends the request to the selected backend

Important notes

  • Use the $http_... variable format for headers:
    • X-Api-Version → $http_x_api_version
    • X-Tenant-Id → $http_x_tenant_id
  • Header names are lowercased and dashes become underscores in variable form
  • map is usually better than if for this use case

Routing by multiple headers

You can also combine headers:

map "$http_x_api_version:$http_x_tenant_id" $backend_upstream {
    default         v1_backend;
    "v2:tenant1"    v2_backend;
}

If you want header-based routing plus path-based routing

You can combine both using separate location blocks and map.

If you want, I can give you:

  1. a full NGINX API gateway config,
  2. routing by JWT claim/header,
  3. routing by tenant header,
  4. or an NGINX Plus / open-source comparison.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.