Skip to content

feat: add backends config option for nginx#80

Merged
AaronFeledy merged 2 commits into
mainfrom
feature/backends
Feb 20, 2026
Merged

feat: add backends config option for nginx#80
AaronFeledy merged 2 commits into
mainfrom
feature/backends

Conversation

@AaronFeledy
Copy link
Copy Markdown
Member

@AaronFeledy AaronFeledy commented Feb 20, 2026

Summary

Adds a backends config option to the nginx service, allowing users to declare an array of upstream Lando services that nginx depends on and can proxy to.

Closes #5

The Problem

When multiple PHP services use via: nginx, they all get the same fpm network alias. Nginx can't distinguish which PHP-FPM backend belongs to which nginx instance, causing round-robin chaos.

The Solution

A new backends array config:

services:
  frontend:
    type: nginx
    backends:
      - backend1
      - backend2

This will:

  1. Add Docker depends_on for the listed services (ensuring startup order)
  2. Allow the vhost config to reference backends by their service name (Docker hostname)
  3. Not break any existing configs (backwards compatible — defaults to empty array)

Status

  • Leia test example added (examples/backends/)
  • CI workflow updated
  • Builder implementation (next step — waiting for tests to fail first, TDD style)

Note

Medium Risk
Moderate risk because it changes how nginx services are rendered into Docker Compose (adds depends_on and env vars), which could affect startup behavior for users who adopt the new option.

Overview
Adds a new backends config option to the nginx service builder; when set, it generates Docker depends_on entries for the named services and exports LANDO_NGINX_BACKENDS into the container environment for template/vhost use.

Introduces a new examples/backends Leia test fixture (frontend proxying to two nginx backends) and wires it into the PR GitHub Actions matrix so the new behavior is exercised in CI.

Written by Cursor Bugbot for commit 06a5726. This will update automatically on new commits. Configure here.

Adds test infrastructure for nginx backends feature (issue #5).
This allows an nginx service to declare upstream backend services
that it depends on and can proxy to.

Tests will fail until the backends config option is implemented.
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 20, 2026

Deploy Preview for lando-nginx failed. Why did it fail? →

Name Link
🔨 Latest commit 06a5726
🔍 Latest deploy log https://app.netlify.com/projects/lando-nginx/deploys/6997bed628e51b0008014540

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

Comment thread .github/workflows/pr-nginx-tests.yml
@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 20, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: CI tests will fail without builder backends implementation
    • Added backends configuration support to nginx builder by initializing backends as empty array in config and generating depends_on entries when backends are specified.

View PR

Or push these changes by commenting:

@cursor push 9ee8a58b87
Preview (9ee8a58b87)
diff --git a/builders/nginx.js b/builders/nginx.js
--- a/builders/nginx.js
+++ b/builders/nginx.js
@@ -26,6 +26,7 @@
       '1.17',
       '1.16',
     ],
+    backends: [],
     pinPairs: {
       '1': 'bitnamilegacy/nginx:1.29.1-debian-12-r0',
       '1.29': 'bitnamilegacy/nginx:1.29.1-debian-12-r0',
@@ -108,6 +109,11 @@
         ],
       };
 
+      // Add backend dependencies if specified
+      if (options.backends && options.backends.length > 0) {
+        nginx.depends_on = options.backends;
+      }
+
       // Send it downstream
       super(id, options, {services: _.set({}, options.name, nginx)});
     }

Adds a 'backends' array config to the nginx service builder.
When specified, it:
- Adds depends_on entries ensuring backend services start first
- Injects LANDO_NGINX_BACKENDS env var with comma-separated service names
- Fully backwards compatible (defaults to empty array)

Closes #5
@AaronFeledy AaronFeledy merged commit 06a5726 into main Feb 20, 2026
38 of 42 checks passed
@AaronFeledy AaronFeledy deleted the feature/backends branch February 20, 2026 04:35
@cursor cursor Bot mentioned this pull request Feb 20, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NGINX Using multiple php-fpm containers

1 participant