Skip to main content

Gateway, login and private access

Edge
A route is a link, and everything on the route is an attribute

An application is reachable from outside because a link from the gateway to it exists. Rate limits, CORS, allow-lists, login and the web application firewall are attributes and links around that route — so they are reviewed, versioned and regenerated like the rest of the stack.

GLOBAL RULEVPN guard403 off-tunnel4000 · 3000CORS · IPscors · whitelist2650WAF profilewaf-<app> link2599login<app>-client1002rate limitper client IPUPSTREAMyour appover its Serviceglobal rules first, then the route plugins by priority, highest firsteach step renders only when its link or attribute is on the graph
What a request meets on an application route, in the order APISIX runs it. The numbers are plugin priorities. Without the links and attributes, the route is plain TLS to the application.

A link apisix-<type> from the APISIX component to a component generates its route:

GeneratedFrom
A route on <subdomain>.<domain>, plus any additional_domain linesThe link's subdomain and the stack's domain
An upstream to the component's in-cluster ServiceThe component's name and namespace
TLS with the stack's wildcard certificatecert-manager
The plugins below, each only when its attribute is setThe link's attributes

An application without a gateway link has no route and is reachable only inside the cluster. Machine-facing routes — the AI gateway, vLLM, KServe, the Kafka bridge, Loki, the Prometheus ingress, the stack agent and the MCP server — carry key authentication from their own link attributes.

The options on an application route​

These are the attributes of the apisix-external_source_code link. Other route types carry the subset their template reads.

AttributeRendersKnow this
rate_limiting + rate_limit_countlimit-count: that many requests per 60 seconds per client addressCounted on each gateway replica. A page or client that makes many calls from one address hits it first: raise the count rather than turning the limit off
cors + cors_headerscors, configured by the lines you giveEmpty lines mean every origin. A wildcard is written allow_origins: "*" with the quotes, and never together with allow_credential: true
whitelist + ip_whitelistip-restriction0.0.0.0/0 allows everyone even with the switch on
apisix_oidc_enable (+ apisix_oidc_param)openid-connectSee Login from a link
max_body_sizeclient-control with the maximum request body—
response_headers, remove_response_headersresponse-rewrite: headers set or removed on the way outOne header name per line for removal. Removing a header the cors plugin sets removes it from CORS answers too
proxy_rewrite + headersproxy-rewrite on the way in—
allowed_methods, websocket, apisix_timeoutThe methods the route accepts, WebSocket upgrade, upstream timeouts—

The order a request meets​

APISIX runs global rules before any route plugin, then the route's plugins by priority, highest first. That fixes the order on an application route:

OrderStepPriority
1The VPN guard, when the gateway is VPN-onlyGlobal rule
2CORS4000
3IP allow-list3000
4Web application firewall2650
5Login2599
6Rate limit1002
7The application—

An application gets a login at the gateway from one link, the way every other integration works.

Link the application to a Keycloak client

Draw external_source_code-client to a client sub-component, or client-external_source_code from it. The application receives OIDC_ISSUER_URL, OIDC_DISCOVERY_URL, OIDC_REALM, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET and OIDC_REDIRECT_URIS.

Route Keycloak through the gateway

The apisix-keycloak_operator link gives Keycloak its public host, which becomes the discovery address.

Turn login on for the route

Set apisix_oidc_enable on the application's route link. The route's openid-connect plugin is built from the client's id and secret, the Keycloak host, the stack's domain and the client's realm.

The rules, as the template applies them:

  • The realm is the client's. A client linked client-realm to a realm sub-component lives in that realm, and the login uses it; otherwise the main realm.
  • Hand-written parameters still win. A real apisix_oidc_param block is rendered as it is. The catalog's example block, the one naming keycloak.domain, counts as unset.
  • Login on, but no client link and no parameters: nothing is rendered and the route stays open.
  • An application that runs its own login flow keeps apisix_oidc_enable off. It still gets the client in its environment.

Who may then use the application is decided by Keycloak groups, not by the route — see Identity and secrets.

Web application firewall​

The firewall is CrowdSec's AppSec engine — Coraza with the OWASP Core Rule Set — run as part of the CrowdSec component.

On the graphWhat it does
A waf sub-component on the CrowdSec componentOne profile. Profile i, in name order, listens on port 7422+i behind the Service <crowdsec>-waf
waf-external_source_code or waf-image_base from the profile to an applicationThat application's route gets the crowdsec-appsec plugin, which sends every request to the profile first and enforces the verdict
apisix-crowdsecRequired: it registers the gateway as a bouncer, with a key both templates derive from the same attribute, so no key is exchanged by hand
waf_failure_action on the linkpassthrough: an unreachable profile lets requests through. deny: it refuses them

The profile's attributes:

AttributeMeaning
waf_modedetect: every rule runs out of band, a match raises an alert, nothing is blocked. block: rules run in band and a match is refused with waf_blocked_http_code
waf_collections, waf_rulesetsWhich CrowdSec hub collections are installed and which rule sets run next to the Core Rule Set — for example the virtual patches, one per known CVE
waf_exclusionsOne per line: a rule id, a rule id with a condition on the request, or a rule name. Dropped for this profile only
waf_body_inspection, waf_body_limitWhether request bodies are inspected, and how much of them

Start in detect, read the alerts (in the SIEM with a crowdsec-opensearch link, on its dashboard CrowdSec - Web Application Firewall), add exclusions, then switch to block. Address-level bans are the firewall bouncer's job — see Detection and response.

Private access with the VPN​

The vpn component runs a WireGuard server managed by wg-portal. People sign in with the stack's single sign-on, get a peer, and load it into any WireGuard client.

On the graphWhat it does
vpn componentThe WireGuard server, its portal and a bootstrap Job
A Keycloak client for the portal, vpn-clientSingle sign-on into the portal
apisix-vpnThe portal's own route, always public
vpn-apisixThe guard: every HTTP route of the gateway answers 403 outside the tunnel

What stays public with the guard on: the identity provider, the VPN portal, the MCP server, and the hosts listed in the link's public_hosts (one per line, *.example.com covers every host under it). The stack agent is VPN-only unless its host is listed. public_paths opens URI prefixes on every host; internal_cidrs lets callers from those addresses through without the tunnel.

Things to know before turning it on:

In-cluster callers of public namesThe DAST scanner and Nextcloud's document editing reach VPN-only hosts through their public names from inside the cluster. Put the cluster's pod ranges in internal_cidrs, or the scan sees 403 and reports a clean result
internal_cidrs needs real source addressesTurn on the gateway component's external_traffic; otherwise the gateway sees node addresses and the list matches nothing. The build warns
APIs called from the internetList their hosts in public_hosts: an external caller has no pod address
Peers route one addressA peer's configuration routes only the gateway's public address and carries no DNS line, so tunnels of several stacks can be up together. Give each stack its own tunnel_cidr
Deactivate before deletingDeleting a peer while its tunnel is up cuts that device off the stack until a new peer exists

Without the vpn-apisix link, nothing in the stack changes.

The AI gateway​

An AI gateway sub-component on the APISIX component is a route to one served model, with key auth, a prompt guard, a system prompt, a token budget and an optional fallback, all from attributes. An application reaches it through <app>-ai_gateway and never sees the model server directly — see Private AI.

→ Security, layer by layer · Detection and response