Skip to content

nginx: 302 the "/" path to "/cgi-bin/luci/"#25718

Open
VergilGao wants to merge 1 commit into
openwrt:masterfrom
VergilGao:nginx-add-new-redirect
Open

nginx: 302 the "/" path to "/cgi-bin/luci/"#25718
VergilGao wants to merge 1 commit into
openwrt:masterfrom
VergilGao:nginx-add-new-redirect

Conversation

@VergilGao

@VergilGao VergilGao commented Jan 10, 2025

Copy link
Copy Markdown

This change will prevent the blank
"LuCI - Lua Configuration Interface" screen
from being displayed for the first time
when accessing luci via a url like 192.168.1.1

Maintainer: @Ansuel
Compile tested: (x86/64, 24.10.0-rc4, Edge)
Run tested: (x86/64, 24.10.0-rc4, Edge)

Description:

When using nginx instead of uhttpd, accessing the root url such as "192.168.1.1" or "my-router.lan" will display a blank page and then jump to the luci page like this.
2025-01-10_09-40-08

Just add the following lines to luci.locations:

location =/ {
  return 302 /cgi-bin/luci/;  // Use 302 to avoid permanent redirect caching by browsers
}

by this way, the blank page will no longer be displayed, and nginx can handle the redirect by itself.
Because it is a 301 response, the browser will automatically jump to /cgi-bin/luci/ the next time you visit.
Because it is a 302 response, the browser will automatically jump to /cgi-bin/luci/ the next time you visit. Use 302 to prevent browsers from caching the redirect permanently.

If you still see a blank page when accessing the root url after applying this patch, you need to open the browser console page when accessing, find the Network tab, check Disable Cache, and then access the root url

@VergilGao VergilGao force-pushed the nginx-add-new-redirect branch from 3c14117 to 270f820 Compare January 10, 2025 02:01
@VergilGao VergilGao force-pushed the nginx-add-new-redirect branch 2 times, most recently from d6525bf to 270f820 Compare January 17, 2025 08:13
@Neustradamus

Copy link
Copy Markdown

@Ansuel: Have you seen this PR?

@@ -1,3 +1,7 @@
location =/ {
return 301 /cgi-bin/luci/;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't a permanent redirect be cached in the browser creating issues when accessing a device not running Luci under the same IP/URL later?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, using a 301 would cause the browser to cache the redirect permanently. It might be better to use a 302 instead to avoid potential issues later.

@VergilGao VergilGao changed the title nginx: 301 the "/" path to "/cgi-bin/luci/" nginx: 302 the "/" path to "/cgi-bin/luci/" Dec 4, 2025
@VergilGao VergilGao force-pushed the nginx-add-new-redirect branch 3 times, most recently from 8869eea to de8e099 Compare December 4, 2025 09:02
@VergilGao

Copy link
Copy Markdown
Author

I've updated this PR to resolve merge conflicts and reflect the latest changes from master. Please take another look when you have time!

@GeorgeSapkin

Copy link
Copy Markdown
Member

You should probably bump the PKG_RELEASE.

@BKPepe BKPepe force-pushed the nginx-add-new-redirect branch from de8e099 to 9bbe561 Compare July 5, 2026 09:25
@openwrt

openwrt Bot commented Jul 5, 2026

Copy link
Copy Markdown

Formality Check: Suggestions Available

We completed the verification flow. Please review the formatting overview logs below.

⚠️ STYLISTIC WARNINGS & SUGGESTIONS

Package Release Audit:

  • ⚠️ Package net/nginx content changed without a PKG_RELEASE or version bump

Something broken? Consider reporting an issue.
Running version ca525cc deployed on 2026-07-04 22:49:00 CEST

This change will prevent the blank
"LuCI - Lua Configuration Interface" screen
 from being displayed for the first time
 when accessing luci via a url like 192.168.1.1

Signed-off-by: Tianshuai Gao <cocopriestyu+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants