关于jeecgboot 前后端 部署 使用域名访问的若干问题

如题,先别问为啥。跟着做就是。

因为想让微信回调到本机页面。起先,想通过idea做内网穿透访问到本机,但是访问一直长时间等待,进入不了页面。 没办法,只能部署到Ngix里测试下看看。我也是被坑了很多次。

1、环境准备

1

81

http://2d6c5e65.r2.cpolar.cn

http

http://localhost:81

2024年05月21日 12时04分58秒

2

81

https://2d6c5e65.r2.cpolar.cn

https

http://localhost:81

2024年05月21日 12时04分58秒

3

9090

http://26668dfe.r3.cpolar.cn

http

http://localhost:9090

2024年05月21日 12时05分00秒

4

9090

https://26668dfe.r3.cpolar.cn

https

http://localhost:9090

2024年05月21日 12时05分00秒

2 配置jeecgboot的前端工程 并build 将文件复制到 ngix里去 运行 (请使用我标红的地址,也就是上面的后端 公网域名地址)

3 复制DIST文件到ngix里去 启动

注意配置文件(别问,跟着做一遍先)

  # jeecgboot的前端访问地址
    server {
        listen       81;
        #server_name  前端访问域名;
        server_name  http://2d6c5e65.r2.cpolar.cn;
        #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题
        location / {
            root   html;
            index  index.html index.htm;
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.html?s=$1 last;
                break;
            }
        }
    }

    #jeecgboot后端nginx配置
    upstream 26668dfe.r3.cpolar.cn {
      server 127.0.0.1:9090;
     }  
     
    server {
        listen       80;
        server_name  26668dfe.r3.cpolar.cn;
        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass  http://26668dfe.r3.cpolar.cn;
            
            #ip remote_addr
            proxy_set_header X-Forwarded-Scheme  $scheme;
            proxy_redirect    off;     
            proxy_set_header  Host             $host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
    }

远端电脑 访问测试  注意:第一次访问会慢一些 后面就很快了

  • 11
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值