feat: unified serve.sh with gateway mode support (#1847)

This commit is contained in:
greatmengqi
2026-04-05 21:07:35 +08:00
committed by GitHub
parent 117fa9b05d
commit ca2fb95ee6
11 changed files with 551 additions and 376 deletions
+5 -31
View File
@@ -27,7 +27,7 @@ http {
}
upstream langgraph {
server langgraph:2024;
server ${LANGGRAPH_UPSTREAM};
}
upstream frontend {
@@ -57,9 +57,11 @@ http {
}
# LangGraph API routes
# Rewrites /api/langgraph/* to /* before proxying
# In standard mode: /api/langgraph/* → langgraph:2024 (rewrite to /*)
# In gateway mode: /api/langgraph/* → gateway:8001 (rewrite to /api/*)
# Controlled by LANGGRAPH_UPSTREAM and LANGGRAPH_REWRITE env vars.
location /api/langgraph/ {
rewrite ^/api/langgraph/(.*) /$1 break;
rewrite ^/api/langgraph/(.*) ${LANGGRAPH_REWRITE}$1 break;
proxy_pass http://langgraph;
proxy_http_version 1.1;
@@ -84,34 +86,6 @@ http {
chunked_transfer_encoding on;
}
# Experimental: Gateway-backed LangGraph-compatible API
# Frontend can opt-in via NEXT_PUBLIC_LANGGRAPH_BASE_URL=/api/langgraph-compat
location /api/langgraph-compat/ {
rewrite ^/api/langgraph-compat/(.*) /api/$1 break;
proxy_pass http://gateway;
proxy_http_version 1.1;
# Headers
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_set_header Connection '';
# SSE/Streaming support
proxy_buffering off;
proxy_cache off;
proxy_set_header X-Accel-Buffering no;
# Timeouts for long-running requests
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
# Chunked transfer encoding
chunked_transfer_encoding on;
}
# Custom API: Models endpoint
location /api/models {
proxy_pass http://gateway;