详解nginx 配置多个tomcat共用80端口
场景:项目1放在tomcat1中,项目2放在tomcat2中,两个tomcat放在同一台服务器上,需要共享80端口访问
注意:这里和集群部署是不同的,集群部署是一个项目放在多个tomcat中。
这里通过nginx做反向代理,nginx请到http://nginx.org/en/download.html自行下载,
修改conf/nginx.conf中的server如下:
server{
listen80;
server_name192.168.1.197;
#charsetkoi8-r;
#access_loglogs/host.access.logmain;
location/{
roothtml;
indexindex.htmlindex.htm;
}
#加下面的配置
location/server1{
proxy_passhttp://192.168.1.197:8081/server1;#主要是这里,这是tomcat1的端口和项目
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
client_max_body_size100m;
roothtml;
indexindex.htmlindex.htm;
}
location/server2{
proxy_passhttp://192.168.1.197:8082/server2;#主要是这里,这是tomcat2的端口和项目
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
client_max_body_size100m;
roothtml;
indexindex.htmlindex.htm;
}
好了,这时候就可以使用http://192.168.1.197/server1和http://192.168.1.197/server2分别访问服务了
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下