一个tomcat下的webapp下部署了多个项目,那么nginx的server怎么配置??

一个tomcat下的webapp下部署了多个项目,那么nginx的server怎么配置??

问题描述:

#项目名称(project1,project2...)
upstream tomcat_server1 {
server 192.168.33.113:8080;
}
server {
listen 80;
server_name www.test1.com;
location / {
proxy_pass http://tomcat_server1;
index /project1/toIndex;
}

}

根据你的需求,你就配多个serve段落就行了,比如下面这样

server {
listen 8080;
server_name www.test1.com;
location / {
proxy_pass http://tomcat_server1;
index /project1/toIndex;
}
}
server {
listen 8081;
server_name www.test2.com;
location / {
proxy_pass http://tomcat_server2;
index /project2/toIndex;
}
}

注意不同服务的监听端口要错开就行了
http://www.runoob.com/linux/nginx-install-setup.html