如题,先别问为啥。跟着做就是。
因为想让微信回调到本机页面。起先,想通过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;
}
}
远端电脑 访问测试 注意:第一次访问会慢一些 后面就很快了