update: optimize environment
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
# ==================== 环境变量配置 ====================
|
||||
# 设置默认值(如果命令行没传,就用这里的默认路径)
|
||||
WORKSPACES_ROOT ?= ./test/workspaces
|
||||
PUBLIC_BASE_URL ?= http://localhost
|
||||
PUBLIC_BASE_URL ?= http://192.168.139.3
|
||||
RUNTIME_HOST ?= 0.0.0.0
|
||||
RUNTIME_PORT ?= 8001
|
||||
RUNTIME_BASE_URL ?= http://127.0.0.1:8001
|
||||
BACKEND_HOST ?= 0.0.0.0
|
||||
BACKEND_PORT ?= 8000
|
||||
|
||||
# 将变量导出给 Makefile 启动的所有子进程
|
||||
export WORKSPACES_ROOT
|
||||
export PUBLIC_BASE_URL
|
||||
export RUNTIME_BASE_URL
|
||||
|
||||
.PHONY: runtime backend
|
||||
|
||||
|
||||
@@ -134,6 +134,7 @@ async def verify_jupyter_access(
|
||||
|
||||
target_port = ws_info.get("port")
|
||||
jupyter_token = ws_info.get("token")
|
||||
jupyter_base_url = ws_info.get("base_url")
|
||||
|
||||
if not target_port:
|
||||
raise HTTPException(
|
||||
@@ -141,6 +142,6 @@ async def verify_jupyter_access(
|
||||
)
|
||||
|
||||
# 通过 Response Header 返回 Upstream 地址与 Token 给 Nginx
|
||||
response.headers["x-upstream-addr"] = f"http://192.168.139.3:{target_port}"
|
||||
response.headers["x-upstream-addr"] = f"{jupyter_base_url}:{target_port}"
|
||||
response.headers["x-jupyter-internal-token"] = jupyter_token or ""
|
||||
return {"status": "ok"}
|
||||
|
||||
@@ -3,10 +3,49 @@ map $http_upgrade $connection_upgrade {
|
||||
'' close;
|
||||
}
|
||||
|
||||
upstream rustfs_backend {
|
||||
server 8.153.151.51:9000;
|
||||
keepalive 64;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
# 全局或针对存储服务设置最大上传限制 (100G)
|
||||
client_max_body_size 100G;
|
||||
|
||||
# =========================================================================
|
||||
# 1. RustFS 对象存储服务转发 (/storage/)
|
||||
# =========================================================================
|
||||
location /storage/ {
|
||||
# 核心:透传 Host,确保 RustFS 生成的 Presigned URL 包含公网地址
|
||||
proxy_set_header Host $http_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;
|
||||
|
||||
# 转发至 RustFS
|
||||
# 注意:如果 RustFS 内部接口也是 /storage/...,请把末尾的 / 去掉
|
||||
proxy_pass http://rustfs_backend/;
|
||||
|
||||
# HTTP/1.1 长连接支持
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
|
||||
# 性能优化:关闭双向 Buffer,实现大文件流式传输
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
|
||||
# 大文件传输超时设置
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
|
||||
# =========================================================================
|
||||
# 2. Jupyter 服务配置
|
||||
# =========================================================================
|
||||
# 拒绝直接访问目录
|
||||
location ~ ^/jupyter/(?<workspace_id>[^/]+)/?$ {
|
||||
return 403 "Direct directory access is forbidden. Please specify a notebook path.";
|
||||
}
|
||||
|
||||
+3
-1
@@ -17,4 +17,6 @@ services:
|
||||
context: .
|
||||
dockerfile: runtime/Dockerfile
|
||||
ports:
|
||||
- "8001:8001"
|
||||
- "8001:8001"
|
||||
environment:
|
||||
- PUBLIC_BASE_URL=http://runtime
|
||||
Reference in New Issue
Block a user