blade-saber前端部署报错

Blade 已结 1 101
mavshuang
mavshuang 剑侠 2024-10-17 07:42

一、该问题的重现步骤是什么?

image.png


二、你期待的结果是什么?实际看到的又是什么?

参考:https://www.kancloud.cn/smallchill/saber/1302089 中部署前端,nginx安装在/datastor/nginx/app/nginx目录下,配置文件为:

user root;

worker_processes 1;


error_log /datastor/nginx/app/nginx/logs/error.log warn;

pid    /datastor/nginx/app/nginx/logs/nginx.pid;



events {

 worker_connections 1024;

}


http {

 include    /datastor/nginx/app/nginx/conf/mime.types;

 default_type application/octet-stream;


 log_format main '$remote_addr - $remote_user [$time_local] "$request" '

          '$status $body_bytes_sent "$http_referer" '

          '"$http_user_agent" "$http_x_forwarded_for"';


 access_log /datastor/nginx/app/nginx/logs/access.log main;

 sendfile    on;

 #tcp_nopush   on;

 keepalive_timeout 65;

 # 启用 Gzip 压缩

 gzip on;

 gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


 #include /etc/nginx/conf.d/*.conf;

 upstream gateway {

  server XXXXXXX:28080 weight=1 max_fails=3 fail_timeout=30s;

}

 server {

  listen    8000;

  server_name web;

  root     /datastor/nginx/app/nginx/html;

  location / {

limit_req zone=one burst=5;

  }


  location ^~/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;

     proxy_buffering off;

     rewrite ^/api/(.*)$ /$1 break;

     proxy_pass http://gateway;

 

  # 优化 proxy 配置

     proxy_connect_timeout 300s;

     proxy_send_timeout 300s;

     proxy_read_timeout 300s;

     proxy_http_version 1.1;

     proxy_set_header Connection "";

  }

 }

}

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

后端使用的是Spring Boot 4.1.0版本,在乌班图系统上,端口是28080

前端配置文件修改:

image.png

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。


1条回答
  •  admin
    admin (最佳回答者)
    2024-10-17 09:42

    VITE_APP_API=/api

    改成这样试试

    作者追问:2024-10-17 09:42

    大佬,刚替换了下,还是不行,大佬的qq联系方式多少,加下咨询下可以吗?

    回答: 2024-10-17 09:42

    这几个看下详细的错,包括返回以及http的状态码(点击浏览器右侧的载荷等窗口然后截图)

    CleanShot20241017170335@2x.png

    作者追问:2024-10-17 09:42

    image.png

    image.png

    image.png

    image.png

    nginx中错误日志如下:

    image.png

    日志信息如下:

    2024/10/17 18:24:32 [error] 1511329#0: *178 open() "/datastor/nginx/app/nginx/html/favicon.ico" failed (2: No such file or directory), client: 167.94.145.106, server: web, request: "GET /favicon.ico HTTP/1.1", host: "47.116.212.184:8000"
    2024/10/17 18:34:31 [error] 1511329#0: *181 open() "/datastor/nginx/app/nginx/html/favicon.ico" failed (2: No such file or directory), client: 36.112.191.189, server: web, request: "GET /favicon.ico HTTP/1.1", host: "47.116.212.184:8000", referrer: "http://47.116.212.184:8000/"
    2024/10/17 18:34:31 [error] 1511329#0: *180 connect() failed (111: Unknown error) while connecting to upstream, client: 36.112.191.189, server: web, request: "GET /api/blade-auth/captcha HTTP/1.1", upstream: "http://172.21.12.41:80/blade-auth/captcha", host: "47.116.212.184:8000", referrer: "http://47.116.212.184:8000/login"
    2024/10/17 18:34:31 [error] 1511329#0: *181 connect() failed (111: Unknown error) while connecting to upstream, client: 36.112.191.189, server: web, request: "GET /api/blade-system/tenant/info?domain=http:%2F%2F47.116.212.184:8000%2Flogin HTTP/1.1", upstream: "http://172.21.12.41:80/blade-system/tenant/info?domain=http:%2F%2F47.116.212.184:8000%2Flogin", host: "47.116.212.184:8000", referrer: "http://47.116.212.184:8000/login"
    2024/10/17 18:34:35 [error] 1511329#0: *188 connect() failed (111: Unknown error) while connecting to upstream, client: 36.112.191.189, server: web, request: "POST /api/blade-auth/token?grantType=password&tenantId=000000&account=admin&password=49f191c154a05d369e9f960852f2e6d24edec43237bafda6f41c40461d47f57a8a91c48e2bb00d33e947cfb596ad64a4077835314a766ce6bbaa3f50b6202ea743625ed42ae5b58d6a44aa9e89fcb7ae08200329cf9895135892fc14ceae7be5772e32078c&type=account HTTP/1.1", upstream: "http://172.21.12.41:80/blade-auth/token?grantType=password&tenantId=000000&account=admin&password=49f191c154a05d369e9f960852f2e6d24edec43237bafda6f41c40461d47f57a8a91c48e2bb00d33e947cfb596ad64a4077835314a766ce6bbaa3f50b6202ea743625ed42ae5b58d6a44aa9e89fcb7ae08200329cf9895135892fc14ceae7be5772e32078c&type=account", host: "47.116.212.184:8000", referrer: "http://47.116.212.184:8000/login"


    回答: 2024-10-17 09:42

    反向代理的地址无法连接,连接超时了,所以返回502状态。

    你在nginx服务器ping一下你反向代理的接口地址,等可以ping通就说明可以反向代理成功


    0 讨论(2)
提交回复