简单分离
比如一个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