ant-vue-desgin + nginx(项目站点) +nginx(门户站点)

1、主站点方向代理test指向项目服务器
主站点反向代理配置

server {
        listen       80;
        server_name  www.main.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main; 
 
        index index.html;
		
        root  ./html;  
        #反向代理test指向项目服务器
		location /test {
           #root   html;
           #index  index.html index.htm;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $remote_addr;
           proxy_set_header X-Forwarded-For $remote_addr;
		       client_max_body_size 220m;
           proxy_pass http://www.project:3000/test;
        }

2、项目nginx将打包的vue打包
2.1)vue打包配置
vue.config.js

 productionSourceMap: true,
 #publicPath名称与主站点反向代理路径(/test) 一致。
  publicPath: '/test/',
  assetsDir: 'static',

2.2)项目nginx配置

server {
        listen       3000 ;
        server_name  www.project.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;  
        index index.html;		
        #dist上传的路径  
       root  E://cszjz//jeecg-boot-master1//jeecg-boot-master//ant-design-vue-jeecg//dist; 
		location /test/ {
		#虚拟路径
			alias   E://cszjz//jeecg-boot-master1//jeecg-boot-master//ant-design-vue-jeecg//dist//;
			 # 避免访问出现 404 错误,页面不能刷新问题
			try_files $uri $uri/ @router;
            index  index.html;
		}	
		#后端请求代理转发
		location ^~ /jeecg-boot {  
		             # 能从项目ip访问到 的内网IP 或内网域名
                      proxy_pass              http://192.168.1.65:9090/jeecg-boot/;  
                      proxy_set_header        Host jeecg-boot-system;  
                      proxy_set_header        X-Real-IP \$remote_addr;  
                      proxy_set_header        X-Forwarded-For \$proxy_add_x_forwarded_for;  
        }  
		  
		 #图片缓存,缓存时长 1天
		location ~ .*\.(gif|jpg|png|css|js|flv|ico|swf)?$
		{
		 expires       1d;
		}

	 
        location @router {
          rewrite ^.*$ /index.html last;
        }  

vue打包文件列表
在这里插入图片描述
4、vue配置后端请求地址

#(项目做了jeecg-boo反向代理,项目在外网嫩访问)项目外网ip和端口端口或(门户做了jeecg-boot反向代理情况下门户的IP和端口与jeecg-boot
#http://www.project.com/jeecg-boot 或 http://www.portal.com/jeecg
VUE_APP_API_BASE_URL=http://192.168.1.65:3000/jeecg-boot
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值