fix:修改webui默认配置暴露端口为127.0.0.1

将 WebUI 服务的默认监听地址从 0.0.0.0 修改为 127.0.0.1,以提升安全性,默认仅允许本地访问。同步调整了相关日志提示以及 template.env 中的注释说明,明确如何在需要时显式开启对外访问。
This commit is contained in:
陈曦
2025-12-14 16:40:37 +08:00
parent a5dbbcc10a
commit 32a6d1a520
3 changed files with 6 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
"""独立的 WebUI 服务器 - 运行在 0.0.0.0:8001"""
"""独立的 WebUI 服务器 - 默认运行在 127.0.0.1:8001"""
import os
import asyncio
@@ -16,7 +16,7 @@ logger = get_logger("webui_server")
class WebUIServer:
"""独立的 WebUI 服务器"""
def __init__(self, host: str = "0.0.0.0", port: int = 8001):
def __init__(self, host: str = "127.0.0.1", port: int = 8001):
self.host = host
self.port = port
self.app = FastAPI(title="MaiBot WebUI")
@@ -178,7 +178,7 @@ def get_webui_server() -> WebUIServer:
global _webui_server
if _webui_server is None:
# 从环境变量读取配置
host = os.getenv("WEBUI_HOST", "0.0.0.0")
host = os.getenv("WEBUI_HOST", "127.0.0.1")
port = int(os.getenv("WEBUI_PORT", "8001"))
_webui_server = WebUIServer(host=host, port=port)
return _webui_server