[PR #1550] [MERGED] Nginx duplicate includes #4421

Closed
opened 2026-02-28 12:00:19 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/0xJacky/nginx-ui/pull/1550
Author: @0xJacky
Created: 2/7/2026
Status: Merged
Merged: 2/8/2026
Merged by: @0xJacky

Base: devHead: cursor/nginx-duplicate-includes-285a


📝 Commits (3)

  • 8b543fe fix: prevent duplicate include directives in nginx.conf
  • 7572865 fix: align Fix function patterns with Check functions and defer backup creation
  • 9b76c1a Fix: Add backup creation for fallback paths in nginx.conf fix functions

📊 Changes

2 files changed (+121 additions, -21 deletions)

View changed files

📝 internal/self_check/nginx_conf.go (+69 -21)
📝 internal/self_check/nginx_conf_test.go (+52 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/0xJacky/nginx-ui/pull/1550 **Author:** [@0xJacky](https://github.com/0xJacky) **Created:** 2/7/2026 **Status:** ✅ Merged **Merged:** 2/8/2026 **Merged by:** [@0xJacky](https://github.com/0xJacky) **Base:** `dev` ← **Head:** `cursor/nginx-duplicate-includes-285a` --- ### 📝 Commits (3) - [`8b543fe`](https://github.com/0xJacky/nginx-ui/commit/8b543fee413cc337ec5a2b7263d241291d6418fe) fix: prevent duplicate include directives in nginx.conf - [`7572865`](https://github.com/0xJacky/nginx-ui/commit/7572865d9114790b96c5a26199a5c4bef8fc9eb3) fix: align Fix function patterns with Check functions and defer backup creation - [`9b76c1a`](https://github.com/0xJacky/nginx-ui/commit/9b76c1a396b7e903681070d0d4ddc629dc10d1e4) Fix: Add backup creation for fallback paths in nginx.conf fix functions ### 📊 Changes **2 files changed** (+121 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `internal/self_check/nginx_conf.go` (+69 -21) 📝 `internal/self_check/nginx_conf_test.go` (+52 -0) </details> ### 📄 Description 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 --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 12:00:19 +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#4421
No description provided.