| @@ -0,0 +1,25 @@ | |||||
| #!/bin/bash | |||||
| baseDir="/home/somuns/ci4s" | |||||
| #判断$1是否为all,如果是,则编译所有模块,否则只编译management-platform模块 | |||||
| if [ "$1" == "all" ]; then | |||||
| buildDir=$baseDir | |||||
| else | |||||
| buildDir="$baseDir/ruoyi-modules/management-platform" | |||||
| fi | |||||
| echo "Building $buildDir" | |||||
| cd $buildDir && mvn clean install | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to build ruoyi-modules" | |||||
| exit 1 | |||||
| fi | |||||
| @@ -0,0 +1,21 @@ | |||||
| #!/bin/bash | |||||
| baseDir="/home/somuns/ci4s" | |||||
| cd ${baseDir}/react-ui | |||||
| npm install | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to install npm depend package" | |||||
| exit 1 | |||||
| fi | |||||
| npm run build | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to build react-ui" | |||||
| exit 1 | |||||
| fi | |||||
| @@ -0,0 +1,74 @@ | |||||
| #!/bin/bash | |||||
| #记录开始时间 | |||||
| startTime=$(date +%s) | |||||
| # 登录到目标环境 | |||||
| baseDir="/home/somuns/ci4s" | |||||
| cd ${baseDir} | |||||
| #build | |||||
| # 默认参数 | |||||
| branch="master" | |||||
| service="manage-front" | |||||
| env="dev" | |||||
| # | |||||
| show_help() { | |||||
| echo "Usage: $0 [-b branch] [-s service] [-e environment]" | |||||
| echo | |||||
| echo "Options:" | |||||
| echo " -b Branch to deploy, default: master" | |||||
| echo " -s Service to deploy (manage-front, manage, front, all, default: manage-front)" | |||||
| echo " -e Environment (e.g., dev, test, default: dev)" | |||||
| echo " -h Show this help message" | |||||
| } | |||||
| # 解析命令行选项 | |||||
| while getopts "b:s:e:h" opt; do | |||||
| case $opt in | |||||
| b) branch=$OPTARG ;; | |||||
| s) service=$OPTARG ;; | |||||
| e) env=$OPTARG ;; | |||||
| h) show_help; exit 0 ;; | |||||
| \?) echo "Invalid option -$OPTARG" >&2; show_help; exit 1 ;; | |||||
| esac | |||||
| done | |||||
| valid_services=("manage-front" "manage" "front" "all") | |||||
| if [[ ! " ${valid_services[@]} " =~ " $service " ]]; then | |||||
| echo "Invalid service name: $service" >&2 | |||||
| echo "Valid services are: ${valid_services[*]}" | |||||
| exit 1 | |||||
| fi | |||||
| valid_envs=("dev" "test") | |||||
| if [[ ! " ${valid_envs[@]} " =~ " $env " ]]; then | |||||
| echo "Invalid environment: $env" >&2 | |||||
| echo "Valid environments are: ${valid_envs[*]}" | |||||
| exit 1 | |||||
| fi | |||||
| echo "start build" | |||||
| sh ${baseDir}/k8s/build.sh -b ${branch} -s ${service} | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Build failed" | |||||
| exit 1 | |||||
| fi | |||||
| echo "build success" | |||||
| # 部署 | |||||
| echo "start deploy" | |||||
| sh ${baseDir}/k8s/deploy.sh -s ${service} -e ${env} | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Deploy failed" | |||||
| exit 1 | |||||
| fi | |||||
| echo "deploy success" | |||||
| # 记录结束时间 | |||||
| endTime=$(date +%s) | |||||
| # 计算运行时间 | |||||
| duration=$(( $endTime - $startTime )) | |||||
| echo "编译发布总耗时: $duration 秒" | |||||
| @@ -0,0 +1,162 @@ | |||||
| #!/bin/bash | |||||
| # 记录开始时间 | |||||
| start=$(date +%s) | |||||
| # 默认参数 | |||||
| service="manage-front" | |||||
| env="dev" | |||||
| show_help() { | |||||
| echo "Usage: $0 [-s service] [-e environment]" | |||||
| echo | |||||
| echo "Options:" | |||||
| echo " -s Service to deploy (manage-front, manage, front, all default: manage-front)" | |||||
| echo " -e Environment (e.g., dev, test, default: dev)" | |||||
| echo " -h Show this help message" | |||||
| } | |||||
| # 解析命令行参数 | |||||
| while getopts "s:e:h" opt; do | |||||
| case $opt in | |||||
| s) service=$OPTARG ;; | |||||
| e) env=$OPTARG ;; | |||||
| h) show_help; exit 0 ;; | |||||
| \?) echo "Invalid option -$OPTARG" >&2; exit 1 ;; | |||||
| esac | |||||
| done | |||||
| echo "Deploy service: $service, environment: $env" | |||||
| valid_services=("manage-front" "manage" "front" "all") | |||||
| if [[ ! " ${valid_services[@]} " =~ " $service " ]]; then | |||||
| echo "Invalid service name: $service" >&2 | |||||
| echo "Valid services are: ${valid_services[*]}" | |||||
| exit 1 | |||||
| fi | |||||
| valid_envs=("dev" "test") | |||||
| if [[ ! " ${valid_envs[@]} " =~ " $env " ]]; then | |||||
| echo "Invalid environment: $env" >&2 | |||||
| echo "Valid environments are: ${valid_envs[*]}" | |||||
| exit 1 | |||||
| fi | |||||
| # 根据环境设置 IP 地址 | |||||
| if [ "$env" == "dev" ]; then | |||||
| remote_ip="172.20.32.181" | |||||
| elif [ "$env" == "test" ]; then | |||||
| remote_ip="172.20.32.185" | |||||
| else | |||||
| echo "Invalid environment - $env" | |||||
| exit 1 | |||||
| fi | |||||
| baseDir=/home/somuns/ci4s | |||||
| tag=$(date +'%Y%m%d%H%M') | |||||
| remote_deploy_dir=/home/deploy/manage-platform | |||||
| # 构建镜像函数 | |||||
| build_image() { | |||||
| local dockerfile=$1 | |||||
| local image=$2 | |||||
| cd ${baseDir}/k8s/dockerfiles | |||||
| docker build -t ${image} -f ${dockerfile} . | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Build ${image} image fail" | |||||
| exit 1 | |||||
| fi | |||||
| docker push ${image} | |||||
| } | |||||
| # 复制和替换 YAML 文件函数 | |||||
| prepare_yaml() { | |||||
| local yaml_file=$1 | |||||
| local image=$2 | |||||
| placeholder="\${${yaml_file%.yaml}-image}" | |||||
| cd ${baseDir}/k8s/template-yaml | |||||
| cp -rf ${yaml_file} deploy/ | |||||
| cd deploy/ | |||||
| sed -i "s|${placeholder}|${image}|g" ${yaml_file} | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Replace ${image} image fail" | |||||
| exit 1 | |||||
| fi | |||||
| # 建立远程目录并备份文件 | |||||
| ssh root@$remote_ip "mkdir -p ${remote_deploy_dir} && if [ -f ${remote_deploy_dir}/${yaml_file} ]; then mv ${remote_deploy_dir}/${yaml_file} ${remote_deploy_dir}/${yaml_file}.bak; fi" | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to create remote directory or backup ${yaml_file}" | |||||
| exit 1 | |||||
| else | |||||
| echo "Successfully created remote directory and backup ${yaml_file}" | |||||
| fi | |||||
| scp ${baseDir}/k8s/template-yaml/deploy/${yaml_file} root@$remote_ip:${remote_deploy_dir}/${yaml_file} | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to copy ${yaml_file}" | |||||
| exit 1 | |||||
| else | |||||
| echo "Successfully copied ${yaml_file}" | |||||
| fi | |||||
| } | |||||
| # 部署服务函数 | |||||
| deploy_service() { | |||||
| local yaml_file=$1 | |||||
| ssh root@$remote_ip "kubectl apply -n argo -f ${remote_deploy_dir}/${yaml_file}" | |||||
| if [ $? -ne 0 ]; then | |||||
| echo "Failed to deploy ${yaml_file}" | |||||
| exit 1 | |||||
| else | |||||
| echo "Successfully deployed ${yaml_file}" | |||||
| fi | |||||
| } | |||||
| deploy_nacos() { | |||||
| local yaml_file=$1 | |||||
| scp ${baseDir}/k8s/${yaml_file} root@$remote_ip:${remote_deploy_dir}/${yaml_file} | |||||
| deploy_service ${yaml_file} | |||||
| } | |||||
| build_and_deploy() { | |||||
| local dockerfile=$1 | |||||
| local image=$2 | |||||
| local yaml_file=$3 | |||||
| build_image ${dockerfile} ${image} | |||||
| prepare_yaml ${yaml_file} ${image} | |||||
| deploy_service ${yaml_file} | |||||
| } | |||||
| # 构建和部署 manage 服务 | |||||
| if [ "$service" == "manage-front" ] || [ "$service" == "manage" ]; then | |||||
| build_and_deploy "managent-dockerfile" "172.20.32.187/ci4s/ci4s-managent:${tag}" "k8s-7management.yaml" | |||||
| fi | |||||
| # 构建和部署 front 服务 | |||||
| if [ "$service" == "manage-front" ] || [ "$service" == "front" ]; then | |||||
| build_and_deploy "nginx-dockerfile" "172.20.32.187/ci4s/ci4s-front:${tag}" "k8s-12front.yaml" | |||||
| fi | |||||
| if [ "$service" == "all" ]; then | |||||
| #部署前端 | |||||
| build_and_deploy "nginx-dockerfile" "172.20.32.187/ci4s/ci4s-front:${tag}" "k8s-12front.yaml" | |||||
| #部署管理平台 | |||||
| build_and_deploy "managent-dockerfile" "172.20.32.187/ci4s/ci4s-managent:${tag}" "k8s-7management.yaml" | |||||
| #部署认证中心 | |||||
| build_and_deploy "auth-dockerfile" "172.20.32.187/ci4s/ci4s-auth:${tag}" "k8s-5auth.yaml" | |||||
| #部署网关 | |||||
| build_and_deploy "gateway-dockerfile" "172.20.32.187/ci4s/ci4s-gateway:${tag}" "k8s-4gateway.yaml" | |||||
| #部署系统服务 | |||||
| build_and_deploy "system-dockerfile" "172.20.32.187/ci4s/ci4s-system:${tag}" "k8s-6system.yaml" | |||||
| #部署配置中心 | |||||
| deploy_nacos "k8s-3nacos.yaml" | |||||
| fi | |||||
| # 记录结束时间 | |||||
| end=$(date +%s) | |||||
| echo "部署成功, 耗时: $((end-start))秒" | |||||
| @@ -0,0 +1,64 @@ | |||||
| worker_processes 1; | |||||
| events { | |||||
| worker_connections 1024; | |||||
| } | |||||
| http { | |||||
| include mime.types; | |||||
| default_type application/octet-stream; | |||||
| sendfile on; | |||||
| keepalive_timeout 65; | |||||
| client_max_body_size 20480m; | |||||
| server { | |||||
| listen 8000; | |||||
| server_name localhost; | |||||
| location /api/{ | |||||
| # rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| proxy_set_header Host $http_host; | |||||
| proxy_set_header X-Real-IP $remote_addr; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_pass http://ci4s-gateway-service.argo.svc:8082/; | |||||
| proxy_connect_timeout 500s; # 设置连接超时时间为 120 秒 | |||||
| proxy_read_timeout 500s; # 设置读取超时时间为 120 秒 | |||||
| proxy_send_timeout 500s; # 设置发送超时时间为 120 秒 | |||||
| } | |||||
| location /label-studio/ { | |||||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||||
| proxy_pass http://label-studio-service.argo.svc:8080/projects/; | |||||
| proxy_hide_header X-Frame-Options; | |||||
| add_header X-Frame-Options ALLOWALL; | |||||
| } | |||||
| location / { | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| root /home/ruoyi/projects/ruoyi-ui; | |||||
| try_files $uri $uri/ /index.html; | |||||
| index index.html index.htm; | |||||
| } | |||||
| location /api/v1/model/ { | |||||
| proxy_pass http://pipeline-convert-service.argo.svc:80; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| } | |||||
| location @router { | |||||
| rewrite ^.*$ /index.html last; | |||||
| } | |||||
| # 避免actuator暴露 | |||||
| if ($request_uri ~ "/actuator") { | |||||
| return 403; | |||||
| } | |||||
| error_page 500 502 503 504 /50x.html; | |||||
| location = /50x.html { | |||||
| root html; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,131 @@ | |||||
| worker_processes 1; | |||||
| events { | |||||
| worker_connections 1024; | |||||
| } | |||||
| http { | |||||
| include mime.types; | |||||
| default_type application/octet-stream; | |||||
| sendfile on; | |||||
| keepalive_timeout 65; | |||||
| client_max_body_size 20480m; | |||||
| error_log /var/log/nginx/error.log debug; | |||||
| server { | |||||
| listen 8000; | |||||
| server_name localhost; | |||||
| location /api/{ | |||||
| # rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| proxy_set_header Host $http_host; | |||||
| proxy_set_header X-Real-IP $remote_addr; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_pass http://ci4s-gateway-service.argo.svc:8082/; | |||||
| proxy_connect_timeout 500s; # 设置连接超时时间为 120 秒 | |||||
| proxy_read_timeout 500s; # 设置读取超时时间为 120 秒 | |||||
| proxy_send_timeout 500s; # 设置发送超时时间为 120 秒 | |||||
| } | |||||
| location /label-studio/ { | |||||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||||
| proxy_pass http://label-studio-service.argo.svc:8080/projects/; | |||||
| proxy_hide_header X-Frame-Options; | |||||
| add_header X-Frame-Options ALLOWALL; | |||||
| } | |||||
| location / { | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| root /home/ruoyi/projects/ruoyi-ui; | |||||
| try_files $uri $uri/ /index.html; | |||||
| index index.html index.htm; | |||||
| } | |||||
| location /api/v1/model/ { | |||||
| proxy_pass http://pipeline-convert-service.argo.svc:80; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| } | |||||
| # location /api/v1/realtimeStatus { | |||||
| # proxy_pass http://argo-server.argo.svc:2746/api/v1/workflow-events/argo; | |||||
| # proxy_set_header REMOTE-HOST $remote_addr; | |||||
| # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| # } | |||||
| location /api/v1/tensorboard/show { | |||||
| # 提取查询参数中的 `svc` 值 | |||||
| set $svc ""; | |||||
| if ($arg_svc) { | |||||
| set $svc $arg_svc; | |||||
| } | |||||
| # 将请求转发到动态生成的内部服务地址 | |||||
| proxy_pass http://$svc.argo.svc:6006; | |||||
| # 传递必要的头信息 | |||||
| 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; | |||||
| # 对于 WebSocket 应用很重要 | |||||
| proxy_buffering off; | |||||
| } | |||||
| location /api/v1/realtimeStatus { | |||||
| rewrite ^/api/v1/realtimeStatus(.*)$ /api/v1/workflow-events/argo$1 break; | |||||
| proxy_pass https://argo-server.argo.svc:2746; | |||||
| proxy_http_version 1.1; | |||||
| proxy_set_header Host $host; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_set_header X-Forwarded-Proto $scheme; | |||||
| # 保留查询参数 | |||||
| proxy_set_header X-Original-URI $request_uri; | |||||
| # 禁用缓冲 | |||||
| proxy_buffering off; | |||||
| # 增加超时时间 | |||||
| proxy_read_timeout 3600s; | |||||
| proxy_send_timeout 3600s; | |||||
| proxy_connect_timeout 60s; | |||||
| # 设置传递的请求头 | |||||
| # proxy_set_header Connection ''; | |||||
| # chunked_transfer_encoding off; | |||||
| # 如果需要保留自定义头部 | |||||
| proxy_set_header Accept 'text/event-stream'; | |||||
| } | |||||
| location /newlog/realtimeLog { | |||||
| proxy_pass http://loki.loki-log.svc:3100/loki/api/v1/tail; | |||||
| proxy_http_version 1.1; | |||||
| proxy_set_header Upgrade $http_upgrade; | |||||
| proxy_set_header Connection "Upgrade"; | |||||
| 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; | |||||
| } | |||||
| location @router { | |||||
| rewrite ^.*$ /index.html last; | |||||
| } | |||||
| # 避免actuator暴露 | |||||
| if ($request_uri ~ "/actuator") { | |||||
| return 403; | |||||
| } | |||||
| error_page 500 502 503 504 /50x.html; | |||||
| location = /50x.html { | |||||
| root html; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,60 @@ | |||||
| worker_processes 1; | |||||
| events { | |||||
| worker_connections 1024; | |||||
| } | |||||
| http { | |||||
| include mime.types; | |||||
| default_type application/octet-stream; | |||||
| sendfile on; | |||||
| keepalive_timeout 65; | |||||
| server { | |||||
| listen 8000; | |||||
| server_name localhost; | |||||
| location /api/{ | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| proxy_set_header Host $http_host; | |||||
| proxy_set_header X-Real-IP $remote_addr; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_pass http://ci4s-gateway-service.argo.svc:8082/; | |||||
| } | |||||
| location /label-studio { | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| proxy_pass http://label-studio-ls-app.label-data.svc:80/; | |||||
| proxy_hide_header X-Frame-Options; | |||||
| add_header X-Frame-Options "ALLOW-FROM http://label-studio-ls-app.label-data.svc:80/"; | |||||
| } | |||||
| location /api/v1/model/ { | |||||
| proxy_pass http://pipeline-convert-service.argo.svc:80; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| } | |||||
| location / { | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| root /home/ruoyi/projects/ruoyi-ui; | |||||
| try_files $uri $uri/ /index.html; | |||||
| index index.html index.htm; | |||||
| } | |||||
| location @router { | |||||
| rewrite ^.*$ /index.html last; | |||||
| } | |||||
| # 避免actuator暴露 | |||||
| if ($request_uri ~ "/actuator") { | |||||
| return 403; | |||||
| } | |||||
| error_page 500 502 503 504 /50x.html; | |||||
| location = /50x.html { | |||||
| root html; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,110 @@ | |||||
| worker_processes 1; | |||||
| events { | |||||
| worker_connections 1024; | |||||
| } | |||||
| http { | |||||
| include mime.types; | |||||
| default_type application/octet-stream; | |||||
| sendfile on; | |||||
| keepalive_timeout 65; | |||||
| client_max_body_size 20480m; | |||||
| error_log /var/log/nginx/error.log debug; | |||||
| server { | |||||
| listen 8000; | |||||
| server_name localhost; | |||||
| location /api/{ | |||||
| # rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| proxy_set_header Host $http_host; | |||||
| proxy_set_header X-Real-IP $remote_addr; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_pass http://ci4s-gateway-service.argo.svc:8082/; | |||||
| proxy_connect_timeout 500s; # 设置连接超时时间为 120 秒 | |||||
| proxy_read_timeout 500s; # 设置读取超时时间为 120 秒 | |||||
| proxy_send_timeout 500s; # 设置发送超时时间为 120 秒 | |||||
| } | |||||
| location /label-studio/ { | |||||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||||
| proxy_pass http://label-studio-service.argo.svc:8080/projects/; | |||||
| proxy_hide_header X-Frame-Options; | |||||
| add_header X-Frame-Options ALLOWALL; | |||||
| } | |||||
| location / { | |||||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||||
| root /home/ruoyi/projects/ruoyi-ui; | |||||
| try_files $uri $uri/ /index.html; | |||||
| index index.html index.htm; | |||||
| } | |||||
| location /api/v1/model/ { | |||||
| proxy_pass http://pipeline-convert-service.argo.svc:80; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| } | |||||
| # location /api/v1/realtimeStatus { | |||||
| # proxy_pass http://argo-server.argo.svc:2746/api/v1/workflow-events/argo; | |||||
| # proxy_set_header REMOTE-HOST $remote_addr; | |||||
| # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| # } | |||||
| location /api/v1/realtimeStatus { | |||||
| rewrite ^/api/v1/realtimeStatus(.*)$ /api/v1/workflow-events/argo$1 break; | |||||
| proxy_pass https://argo-server.argo.svc:2746; | |||||
| proxy_http_version 1.1; | |||||
| proxy_set_header Host $host; | |||||
| proxy_set_header REMOTE-HOST $remote_addr; | |||||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||||
| proxy_set_header X-Forwarded-Proto $scheme; | |||||
| # 保留查询参数 | |||||
| proxy_set_header X-Original-URI $request_uri; | |||||
| # 禁用缓冲 | |||||
| proxy_buffering off; | |||||
| # 增加超时时间 | |||||
| proxy_read_timeout 3600s; | |||||
| proxy_send_timeout 3600s; | |||||
| proxy_connect_timeout 60s; | |||||
| # 设置传递的请求头 | |||||
| # proxy_set_header Connection ''; | |||||
| # chunked_transfer_encoding off; | |||||
| # 如果需要保留自定义头部 | |||||
| proxy_set_header Accept 'text/event-stream'; | |||||
| } | |||||
| location /newlog/realtimeLog { | |||||
| proxy_pass http://loki.loki-log.svc:3100/loki/api/v1/tail; | |||||
| proxy_http_version 1.1; | |||||
| proxy_set_header Upgrade $http_upgrade; | |||||
| proxy_set_header Connection "Upgrade"; | |||||
| 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; | |||||
| } | |||||
| location @router { | |||||
| rewrite ^.*$ /index.html last; | |||||
| } | |||||
| # 避免actuator暴露 | |||||
| if ($request_uri ~ "/actuator") { | |||||
| return 403; | |||||
| } | |||||
| error_page 500 502 503 504 /50x.html; | |||||
| location = /50x.html { | |||||
| root html; | |||||
| } | |||||
| } | |||||
| } | |||||