1.利用nginx跳转到指定的tomcat中
假设tomcat启动正常,访问路径为:http://localhost:8080
nginx版本已经获取,且解压完成,nginx访问跟目录中conf/nginx.conf中的监听端口为8095,添加 proxy_pass http://localhost:8080;注意端口后面的分号不能省略。配置完成后,start nginx.bat启动,在浏览器窗口中输入:http://localhost:8095即可跳转到tomcat中,实现简单的nginx代理。
server {
listen 8095;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost:8080;
}
listen 8095;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost:8080;
}
2.利用nginx负载均衡
下文简单描述,使用nginx的负载均衡,实现两个tomcat的跳转,配置方法如下: