nginx 本地 打开 http://localhost:81 跳转不到tomcat,求指点
本地win7搭建测试环境,因80端口被别的程序占用了,我把nginx的监听端口改成81
现在我想做到,在浏览器输入 http://localhost:81 就跳转到 tomcat工程test的首页
最好是不用输入端口号81,输入http://localhost 就能跳转到tomcat工程test的首页
需呀修改哪里,请大神指点。
nginx.conf 配置如下
upstream tomcats.com {
ip_hash;
server 127.0.0.1:8081 weight=1;
server 127.0.0.1:8082 weight=1;
}
server {
listen 81;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcats.com;
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
2个tomcat server.xml配置如下:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" reloadable="false" docBase="E:\java\apache-tomcat-7.0.57-8081\webapps\test"> </Context>
</Host>
1,ie输入: http://localhost :8081 或 http://localhost :8082 可以打开tomcat 下的工程test的首页
2,ie输入: http://localhost :81 打开 nginx 的欢迎界面 Welcome to nginx! 但不跳转到tomcat部署下的工程test界面,这是为什么
3, ie输入 http://localhost :81/test 可以打开tomcat 下的工程test的首页
4,浏览器中输入 http://localhost 什么都打不开,浏览器直接跳转到http://www.ip686.com/了。