feat(frontend): allow configurable backend host and port
This commit is contained in:
@@ -33,6 +33,9 @@ STORAGE_TYPE=local
|
|||||||
# 流处理后端(memory/redis)
|
# 流处理后端(memory/redis)
|
||||||
STREAM_MANAGER_TYPE=redis
|
STREAM_MANAGER_TYPE=redis
|
||||||
|
|
||||||
|
# 应用服务主机名,默认为app
|
||||||
|
APP_HOST=app
|
||||||
|
|
||||||
# 应用服务端口,默认为8080
|
# 应用服务端口,默认为8080
|
||||||
APP_PORT=8080
|
APP_PORT=8080
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ services:
|
|||||||
- "${FRONTEND_PORT:-80}:80"
|
- "${FRONTEND_PORT:-80}:80"
|
||||||
environment:
|
environment:
|
||||||
- MAX_FILE_SIZE_MB=${MAX_FILE_SIZE_MB:-50}
|
- MAX_FILE_SIZE_MB=${MAX_FILE_SIZE_MB:-50}
|
||||||
|
- APP_HOST=${APP_HOST:-app}
|
||||||
|
- APP_PORT=${APP_PORT:-8080}
|
||||||
depends_on:
|
depends_on:
|
||||||
app:
|
app:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ EOF
|
|||||||
|
|
||||||
# 处理 nginx 配置
|
# 处理 nginx 配置
|
||||||
export MAX_FILE_SIZE=${MAX_FILE_SIZE_MB}M
|
export MAX_FILE_SIZE=${MAX_FILE_SIZE_MB}M
|
||||||
envsubst '${MAX_FILE_SIZE}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf
|
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
|
||||||
|
|
||||||
# 启动 nginx
|
# 启动 nginx
|
||||||
exec nginx -g 'daemon off;'
|
exec nginx -g 'daemon off;'
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ server {
|
|||||||
|
|
||||||
# API请求代理到后端服务
|
# API请求代理到后端服务
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://app:8080/api/;
|
proxy_pass http://${APP_HOST}:${APP_PORT}/api/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|||||||
@@ -41,6 +41,11 @@ spec:
|
|||||||
securityContext:
|
securityContext:
|
||||||
{{- toYaml . | nindent 12 }}
|
{{- toYaml . | nindent 12 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: APP_HOST
|
||||||
|
value: {{ .Values.frontend.appHost | default (printf "%s-app" (include "weknora.fullname" .)) | quote }}
|
||||||
|
- name: APP_PORT
|
||||||
|
value: {{ .Values.frontend.appPort | default .Values.app.service.port | quote }}
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: http
|
name: http
|
||||||
|
|||||||
Reference in New Issue
Block a user