Nginx静动分离

简单分离

比如一个SpringBoot项目DivideDynamicStatic
在这里插入图片描述
显然有一个静态图像文件夹static.image。
首先把image文件夹通过xftp传入到Nginx服务器(192.168.93.130)中的html下,然后修改Nginx的配置文件nginx.conf

    server {
        listen       84;
        server_name  DDS;//不能为localhost

        location / {
            proxy_pass http://192.168.93.101:8081;//这里不能带项目名,只能有端口号
        }
		//如果有静态css或者js,都可以做类似的配置
        location /image {
            root   html;
            index  index.html index.htm;
        }
		//如果目录很多的话可以通过正则匹配
		 location ~*/(image|js|css){
            root   html;
            index  index.html index.htm;
        }
    }

把这个项目打包jar之后,通过xftp传入到另一个服务器中,我的是192.168.93.101。通过java -jar DivideDynamicStatic.jar 启动这个项目

最后在浏览器输入 192.168.93.130:84

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值