Nginx gateway
Route requests to multiple services through one URL with nginx.
- app
- proxy
Guide: Run a GitHub repo
Run it
briq run nginxbriq_run({ recipe: "nginx", wait: true })curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipe": "nginx",
"wait": true
}'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "GATEWAY_URL": "…" }, … }
# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
-H "Authorization: Bearer $BRIQ_API_KEY"stack: app
services:
gateway:
recipe: nginx
# its defaults, each a field you can set:
# routes: { "/":"app:8080" }
# size: nanoFields
| Name | Type | Options | Default |
|---|---|---|---|
| routes | record | { "/prefix/": "briq:port" } | {"/":"app:8080"} |
| size | enum | nano, small | "nano" |
| egress | object | { hosts } | — |
Outputs
Returned by briq_run once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.
- GATEWAY_URL
- http://gateway.<stack>.internal
What it runs
| Briq | Image | Ports | Size | Volume |
|---|---|---|---|---|
| gateway | nginx:1-alpine | 80 | nano | — |
When to use it
- An app in several briqs (front end, back end, database), opened at one URL.
- A front end that calls its API at
/api/…: one origin, so no CORS and no API address to build in.
Tips
- Run it last: it reads the addresses of the briqs it routes to, and waits for them to run.
- Routes are path prefixes:
{ "/api/": "backend:8000", "/": "frontend:8080" }. The longest wins, and the path is passed on whole. - End a prefix with
/to match a folder only:/docsalso takes/docs-old. - Name the briqs behind it: run them with
name: "backend"andname: "frontend". - Expose only the gateway: the briqs behind it stay private. Its URL is
gateway-…. - Listen on
::behind it: it reaches them over the private network, which is IPv6. - A 502 for a few seconds means a briq behind it is still starting, after a wake for example.
- Host,
X-Forwarded-Hostand WebSockets go through. - Step by step: Run a GitHub repo.