qi923701
Powerful_Current
采纳率57.1%
2017-10-31 05:00 阅读 6.1k
已采纳

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

1

#项目名称(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;
}

}

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    kingbaron kingbaron 2017-10-31 07:17

    根据你的需求,你就配多个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

    点赞 评论 复制链接分享

相关推荐