mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 08:16:56 +08:00
fix: use heredoc for nginx config to avoid envsubst issues
This commit is contained in:
@@ -16,9 +16,40 @@ if [ -z "$DATA_ENCRYPTION_KEY" ]; then
|
|||||||
export DATA_ENCRYPTION_KEY=$(openssl rand -base64 32)
|
export DATA_ENCRYPTION_KEY=$(openssl rand -base64 32)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 生成 nginx 配置
|
# 生成 nginx 配置(直接写入,避免 envsubst 问题)
|
||||||
echo "📝 Generating nginx config for port $PORT..."
|
echo "📝 Generating nginx config for port $PORT..."
|
||||||
envsubst '${PORT}' < /etc/nginx/nginx.conf.template > /etc/nginx/http.d/default.conf
|
cat > /etc/nginx/http.d/default.conf << NGINX_EOF
|
||||||
|
server {
|
||||||
|
listen $PORT;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain text/css application/json application/javascript;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files \$uri \$uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8081/api/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host \$host;
|
||||||
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
|
proxy_connect_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /health {
|
||||||
|
return 200 'OK';
|
||||||
|
add_header Content-Type text/plain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NGINX_EOF
|
||||||
|
echo "✅ Nginx config generated"
|
||||||
|
cat /etc/nginx/http.d/default.conf
|
||||||
|
|
||||||
# 启动后端(后台运行,端口 8081 避免与 nginx 冲突)
|
# 启动后端(后台运行,端口 8081 避免与 nginx 冲突)
|
||||||
echo "🔧 Starting backend on port 8081..."
|
echo "🔧 Starting backend on port 8081..."
|
||||||
|
|||||||
Reference in New Issue
Block a user