mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-04-25 08:45:58 +03:00
[GH-ISSUE #430] 當server_name設置與本機相同ip時,nginx-ui會出錯 #6024
Labels
No labels
Q/A
bug
casdoor
dependencies
docker
documentation
duplicate
enhancement
help wanted
invalid
lego
platform:openwrt
platform:windows
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-ui#6024
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @chankahou0968 on GitHub (Jul 3, 2024).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/430
Describe the bug
server_name 設置其它 doaminname 或 ip都沒事,只是設置為本機ip時便會出錯
Info (please complete the following information):
version: '3.8'
services:
app:
image: 'uozi/nginx-ui:latest'
container_name: ${NAME}
hostname: ${NAME}
restart: unless-stopped
ports:
- '80:80'
- '443:443'
volumes:
- /mnt/user/appdata/nginx:/etc/nginx
- /mnt/user/appdata/nginx-ui:/etc/nginx-ui
- /var/www:/var/www
environment:
- TZ=Asia/Macau
network_mode: ${NETWORK}
@0xJacky commented on GitHub (Jul 4, 2024):
你好,請問是出現什麼錯誤?
@chankahou0968 commented on GitHub (Jul 4, 2024):
是整個nginx-ui都崩潰了:
詳情是,我的本機ip是202.175.25.224,新增location時要求輸入server_name,
由於沒有domainname,所以我便輸入202.175.25.224,
之後按確定後便系統崩了,browser刷新後連nginx-ui都開不出來了。
解決辦法是進入uozi/nginx-ui:latest的container內,把/etc/nginx/sites-enabled與/etc/nginx/sites-avaible內有文件删掉,
再nginx -s reload後便回覆正常。
希望有解決辦法,謝謝。
@0xJacky commented on GitHub (Jul 4, 2024):
新增 location 的時候,並不會要求輸入 server_name,可否提供一下截圖?
@0xJacky commented on GitHub (Jul 4, 2024):
我在測試環境中無法復現這個問題
@0xJacky commented on GitHub (Jul 4, 2024):
麻煩提供一下 /etc/nginx/sites-avaible 內引發問題的配置文件的內容
@chankahou0968 commented on GitHub (Jul 4, 2024):
圖1是剛啓動的界面;
圖2是新增網站時的界面,我在server_name輸入202.175.25.224 (本機ip),按下一步後,
圖3是界面都還算正常,我甚麼都沒動,但這時已經崩了,因為再按下一步都沒有反應,
圖4是nginx-ui已出錯
圖5是按下刷新後,nginx-ui已刷不出來了
@chankahou0968 commented on GitHub (Jul 4, 2024):
我是用另一台pc(非202.175.25.224)用browser login到nginx-ui進行上述操作的
還有,只要圖2輸入別的內容時,是不會報錯的
謝謝。
@0xJacky commented on GitHub (Jul 4, 2024):
已經可以復現,這個問題是由於 nginx 配置衝突造成的,與 nginx-ui 無關。
因為我們在 docker 容器中的 /etc/nginx/conf.d/nginx-ui.conf 文件內配置了反向代理
server_name localhost;,因此容器內的 Nginx 會監聽 localhost:80,然後通過 docker 的端口映射,我們可以將 外部ip:80 映射到容器內的 80 端口,因此正常情況下反向代理是可以正常工作的。但是如果你新建了一個 server_name 為伺服器的外部 ip,那麼容器內的 nginx 也會監聽這個 ip:80,因此如果你用這個ip去訪問,則他不會走我們配置在 localhost:80 的反向代理規則,因此表現出來的問題就是 404。
由於您目前暫時沒有域名,為了不影響正常業務,我建議:
方案一:
將映射容器內的 nginx-ui 端口(通常情況下是 9000)到服務器上 9000 端口(或者其他),此時在 browser 中可以使用 ip:9000 正常訪問,80 端口及 443 端口可以用於配置其他業務
方案二:
在新配置文件中配置反向代理規則,在 browser 中可以使用 ip/nginx-ui 正常訪問