[PR #1550] Nginx duplicate includes #5767

Closed
opened 2026-03-01 15:42:30 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/0xJacky/nginx-ui/pull/1550

State: closed
Merged: Yes


Prevent duplicate include directives in nginx.conf by making fix functions idempotent.

The FixNginxConfIncludeSites, FixNginxConfIncludeStreams, and FixNginxConfIncludeConfD functions previously appended include directives without checking for existing ones, leading to duplicate entries in nginx.conf if called multiple times. This change adds a check to each function to ensure an include directive is only added if it doesn't already exist.


Open in Cursor Open in Web


Note

Low Risk
Low risk: small, localized changes to nginx.conf self-healing logic plus a test; main risk is false-positive matching on existing include directives due to substring checks.

Overview
Prevents duplicate include directives from being appended to nginx.conf by making FixNginxConfIncludeSites, FixNginxConfIncludeStreams, and FixNginxConfIncludeConfD idempotent (early-return if the target include already exists).

Backup creation is now done only when a change will be made (and still occurs for the no-block append path), and a new test (TestFixNginxConfNoDuplicateIncludes) verifies repeated runs don’t introduce duplicates.

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

**Original Pull Request:** https://github.com/0xJacky/nginx-ui/pull/1550 **State:** closed **Merged:** Yes --- Prevent duplicate include directives in `nginx.conf` by making fix functions idempotent. The `FixNginxConfIncludeSites`, `FixNginxConfIncludeStreams`, and `FixNginxConfIncludeConfD` functions previously appended include directives without checking for existing ones, leading to duplicate entries in `nginx.conf` if called multiple times. This change adds a check to each function to ensure an include directive is only added if it doesn't already exist. --- <p><a href="https://cursor.com/background-agent?bcId=bc-1acdba5c-3a44-40b9-a740-6331ef7daf7a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-1acdba5c-3a44-40b9-a740-6331ef7daf7a"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: small, localized changes to nginx.conf self-healing logic plus a test; main risk is false-positive matching on existing `include` directives due to substring checks. > > **Overview** > Prevents duplicate `include` directives from being appended to `nginx.conf` by making `FixNginxConfIncludeSites`, `FixNginxConfIncludeStreams`, and `FixNginxConfIncludeConfD` **idempotent** (early-return if the target `include` already exists). > > Backup creation is now done only when a change will be made (and still occurs for the no-block append path), and a new test (`TestFixNginxConfNoDuplicateIncludes`) verifies repeated runs don’t introduce duplicates. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9b76c1a396b7e903681070d0d4ddc629dc10d1e4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
kerem 2026-03-01 15:42:30 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#5767
No description provided.