jeecgboot / JeecgBoot

🔥「企业级低代码平台」前后端分离架构SpringBoot 2.x/3.x,SpringCloud,Ant Design&Vue3,Mybatis,Shiro,JWT。强大的代码生成器让前后端代码一键生成,无需写任何代码! 引领新的开发模式OnlineCoding->代码生成->手工MERGE,帮助Java项目解决70%重复工作,让开发更关注业务,既能快速提高效率,帮助公司节省成本,同时又不失灵活性。
http://www.jeecg.com
Apache License 2.0
40.19k stars 14.73k forks source link

nginx 部署没有访问后台问题 #6515

Closed AndrewLiuZhangZong closed 1 year ago

AndrewLiuZhangZong commented 1 year ago
版本号:3.5.3
问题描述:nginx 代理 pnpm build 打包后的dist,后台端口是18080

nginx配置 图片 .env.production配置 图片

截图&代码:

访问的时候前台没有调用18080接口的后台地址,而是还是3100前端地址,好像没有请求代理 图片

zhangdaiscott commented 1 year ago

https://help.jeecg.com/publish/quick.html

AndrewLiuZhangZong commented 1 year ago

如果没有域名哪

AndrewLiuZhangZong commented 1 year ago

https://help.jeecg.com/publish/quick.html

如果没有域名该怎样配置

zhangdaiscott commented 1 year ago

1、nginx映射 2、后台完整地址

无域名没关系

AndrewLiuZhangZong commented 1 year ago

server { listen 3100; server_name localhost;

前端打的dist资源存放目录

root         /www/wwwroot/visionfile/web/dist;
location / {
     # 用于配合 browserHistory使用
     try_files $uri $uri/ /index.html;
}
location  /jeecgboot/ {
    #后台接口地址(我们部署去掉了/jeecg-boot项目名,如果你有请加上)
    proxy_pass         http://127.0.0.1:18080/;
    proxy_redirect off;
    #真实IP获取
    proxy_set_header  Host             $host;
    proxy_set_header  X-Real-IP        $remote_addr;
    set $my_proxy_add_x_forwarded_for $proxy_add_x_forwarded_for;
    if ($proxy_add_x_forwarded_for ~* "127.0.0.1"){
       set $my_proxy_add_x_forwarded_for $remote_addr;
    }
    proxy_set_header   X-Forwarded-For $my_proxy_add_x_forwarded_for;
}
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

}

这样配置nginx 对吗

AndrewLiuZhangZong commented 1 year ago

image 前端配置这样的