feat: support remote backend and HTTPS proxy

This commit is contained in:
wizardchen
2026-02-09 17:27:21 +08:00
committed by lyingbug
parent d72f65bc23
commit bfab05972f
4 changed files with 23 additions and 5 deletions
+12 -2
View File
@@ -33,12 +33,22 @@ STORAGE_TYPE=local
# 流处理后端(memory/redis)
STREAM_MANAGER_TYPE=redis
# 应用服务主机名,默认为app
# 应用服务主机名,默认为app(Docker内部服务名)
# 如需代理到远程后端,可设为远程地址,如 remote-app.example.com
APP_HOST=app
# 应用服务端口,默认为8080
# 应用服务宿主机映射端口,默认为8080(仅影响宿主机访问,不影响容器间通信)
APP_PORT=8080
# NGINX 代理到后端的目标端口,默认为8080(App容器内部监听端口)
# 本地部署:保持默认即可,无需随 APP_PORT 修改
# 远程部署:设为远程 App 服务的实际端口
# APP_BACKEND_PORT=8080
# NGINX 代理到后端的协议,默认为http
# 远程部署如后端为 HTTPS,需设为 https
# APP_SCHEME=http
# 前端服务端口,默认为80
FRONTEND_PORT=80
+7 -1
View File
@@ -11,7 +11,13 @@ services:
environment:
- MAX_FILE_SIZE_MB=${MAX_FILE_SIZE_MB:-50}
- APP_HOST=${APP_HOST:-app}
- APP_PORT=${APP_PORT:-8080}
# APP_BACKEND_PORT: the port NGINX proxies to (default 8080).
# For local deployment this is the App container's listening port, independent of host-mapped APP_PORT.
# For remote deployment, set this to the remote App's service port.
- APP_PORT=${APP_BACKEND_PORT:-8080}
- APP_SCHEME=${APP_SCHEME:-http}
# NOTE: If using a remote App backend, comment out or remove the depends_on
# block below and set APP_HOST/APP_BACKEND_PORT/APP_SCHEME in your .env file.
depends_on:
app:
condition: service_healthy
+2 -1
View File
@@ -11,7 +11,8 @@ EOF
export MAX_FILE_SIZE=${MAX_FILE_SIZE_MB}M
export APP_HOST=${APP_HOST:-app}
export APP_PORT=${APP_PORT:-8080}
envsubst '${MAX_FILE_SIZE} ${APP_HOST} ${APP_PORT}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
export APP_SCHEME=${APP_SCHEME:-http}
envsubst '${MAX_FILE_SIZE} ${APP_HOST} ${APP_PORT} ${APP_SCHEME}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
# 启动 nginx
exec nginx -g 'daemon off;'
+2 -1
View File
@@ -22,8 +22,9 @@ server {
}
# API请求代理到后端服务
# APP_SCHEME 默认 http,远程 HTTPS 后端可设为 https
location /api/ {
proxy_pass http://${APP_HOST}:${APP_PORT}/api/;
proxy_pass ${APP_SCHEME}://${APP_HOST}:${APP_PORT}/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;