现在我在本机上解压了两个tomcat,并改了端口,安装了nginx,也通过网上的博客配置好了反向代理,
我新建了一个简单项目,把它弄到了tomcat1和tomcat2下,测试通过单独的访问tomcat1+项目url可以访问,
单独访问tomcat2也可以访问到项目,可是通过nginx我应该怎么去访问呢?我的tomcat1访问地址为localhost:8081/nginx_test.index.jsp,
tomcat2的访问地址为localhost:8082/nginx_test/index.jsp,nginx改了监听端口为8010,那么我如何通过浏览器去访问两个这个项目呢,如果直接访问localhost:8081/nginx_test/index.jsp,那么nginx的代理作用岂不是没起到,地址栏试过输入host:8010/nginx.jsp,直接报404错,现在我的问题是地址栏应该填什么来确保通过nginx访问到tomcat中的项目
nginx需要加两部分 upstream server
配置你现有的服务,可以再增加
upstream xxx {
server localhost:8081;
server localhost:8082;
}
修改server节点
server {
listen 80;
server_name xxx;
charset utf-8;
location / {
proxy_pass http://xxx;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
}
}
默认为8080和8081两个服务轮询处理请求
配置都配好了现在配置了之后地址栏怎么请求,应该通过输入什么来访问项目