1.背景
最近大的web项目要拆分成小的web项目(JSP写的,很少公司用JSP了),为了解决跨域问题,所以要配置根据上下文不同,返回web项目页面或者提供接口服务。比如:http://172.22.7.25:8080/demo001/,http://172.22.7.25:8081/demo002/(他们是2个web项目demo001 demo002),现在通过nginx配置成http://172.22.7.25:8080/demo001/或者http://172.22.7.25:8080/demo001/访问(他们只是上下文不同)
2.nginx配置
location /demo001 {
proxy_pass http://localhost:8080;
index index.html index.htm;
}
location /demo002 {
proxy_pass http://localhost:8081;
index index.html index.htm;
}