feat: add backends config option for nginx#80
Merged
Conversation
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.
❌ Deploy Preview for lando-nginx failed. Why did it fail? →
|
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a
backendsconfig 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 samefpmnetwork alias. Nginx can't distinguish which PHP-FPM backend belongs to which nginx instance, causing round-robin chaos.The Solution
A new
backendsarray config:This will:
depends_onfor the listed services (ensuring startup order)Status
examples/backends/)Note
Medium Risk
Moderate risk because it changes how nginx services are rendered into Docker Compose (adds
depends_onand env vars), which could affect startup behavior for users who adopt the new option.Overview
Adds a new
backendsconfig option to thenginxservice builder; when set, it generates Dockerdepends_onentries for the named services and exportsLANDO_NGINX_BACKENDSinto the container environment for template/vhost use.Introduces a new
examples/backendsLeia 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.