Skip to content

Nginx UI 2.1.0 版本代理路径有后缀登录异常 #1111

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
davidche1116 opened this issue Jun 4, 2025 · 3 comments
Closed

Nginx UI 2.1.0 版本代理路径有后缀登录异常 #1111

davidche1116 opened this issue Jun 4, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@davidche1116
Copy link

Describe the bug
在 Nginx UI 2.1.0 版本中,通过 Nginx 反向代理添加路径后缀(如 /nginx/)后,登录功能报“服务器异常”,而直接访问后端端口(9000)或回退至 2.0.2 版本均正常。

To Reproduce
Steps to reproduce the behavior:

  1. 安装 Nginx UI 2.1.0,监听 127.0.0.1:9000。
  2. 配置 Nginx 代理:
location /nginx/ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_pass http://127.0.0.1:9000/;  # 注意末尾斜杠
}
  1. 通过 http://your-domain.com/nginx/ 打开 Nginx UI
  2. 输入账号密码点击登录,页面返回“服务器异常”错误。

Expected behavior​
通过代理路径 /nginx/ 应能正常登录,功能与直接访问 127.0.0.1:9000 或 2.0.2 版本一致
理路径下的静态资源(JS/CSS)和 API 请求应正确加载,无会话丢失问题
或者在docker部署的时候,增加配置文件。支持/nginx前缀配置(域名和证书都需要节省,不得已采用这种后缀域名)

Info (please complete the following information):

  • Server OS: Ubuntu 22.04
  • Server Arch:x86_64
  • Nginx UI Version:2.1.0
  • Your Browser: Chrome

Additional context
​​问题根源分析​​:
1.​​Cookie 路径不匹配​​
​​2.静态资源路径错误​​:
前端资源(如 JS/CSS)可能使用绝对路径(如 /static/xxx.js),代理后路径变为 /nginx/static/xxx.js,但资源实际位于后端根路径,导致 404 错误。
3.​​API 请求路径错误​​:
登录请求可能发送至 /api/#,但代理后路径应为 /nginx/api/#,后端路由不匹配。
​​临时解决方案​​:
​​回退版本​​:使用 2.0.2 版本可正常工作。

​​修复建议​​:
1.​​动态路径适配​​:
后端应根据 X-Forwarded-Prefix 头自动调整 Cookie 路径和 API 路由前缀(需 Nginx 配置 proxy_set_header X-Forwarded-Prefix /nginx/;)。
​​2.前端资源路径兼容​​
3.新增支持使用WEB_CONTEXT='/nginx'之类的docker环境变量配置

@davidche1116 davidche1116 added the bug Something isn't working label Jun 4, 2025
@0xJacky
Copy link
Owner

0xJacky commented Jun 4, 2025

刚刚,已经修复

@0xJacky
Copy link
Owner

0xJacky commented Jun 4, 2025

稍后将会发布 v2.1.1

@davidche1116
Copy link
Author

看到了。真快

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants