Nginx+Tomcat7:The page you are looking for is temporarily unavailable.Please try again later.

The page you are looking for is temporarily unavailable.Please try again later.  

问题原因:

在Linux上面部署Nginx+Tomcat负载均衡,两台服务器 一台部署Nginx另一台部署Tomcat运行程序,Tomcat服务器没问题但是linux就是代理不到

解决办法:

查找nginx.conf文件中proxy_pass转发的IP地址是否在本机上和nginx所在的服务器可以访问。

nginx.conf文件中upstream负载均衡配置是否正确

检查被代理的内网ip地址ifconfig

[root@iZ282a7t938Z bin]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3E:02:31:4B  
          inet addr:XXXXX Bcast:10.164.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18945433 errors:0 dropped:0 overruns:0 frame:0
          TX packets:156897 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:894522211 (853.0 MiB)  TX bytes:11720806 (11.1 MiB)
          Interrupt:162 

eth1      Link encap:Ethernet  HWaddr 00:16:3E:02:33:0E  
          inet addr:XXXXXX  Bcast:121.42.47.255  Mask:255.255.252.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:541127214 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8424840 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27250810048 (25.3 GiB)  TX bytes:8234399240 (7.6 GiB)
          Interrupt:161 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:1352 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1352 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:73202 (71.4 KiB)  TX bytes:73202 (71.4 KiB)



#设定负载均衡的服务器列表

     upstream web{
    #weigth参数表示权值,权值越高被分配到的几率越大
    server XXXX1X:3128 weight=5;#本机上的Squid开启3128端口
    server XXXX2x:80  weight=1;
    server XXXX3x:80  weight=6;
    }

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    upstream  web {
	server xxxxxx1:8080;
	ip_hash;
	}
    server {
	 listen      80;
         server_name  www.etz168.com etz168.com;
         location  / {
                proxy_pass http://web;
		proxy_set_header   X-Real-IP            $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_set_header   Host                   $http_host;
                proxy_set_header   X-NginX-Proxy    true;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}


如果不能访问,查看tomcat是否启动了、关闭tomcat时是否有异常、访问的端口是否开启、nginx所在的服务器不能访问外网、只能用内网IP等等。

解决以上问题后,把nginx.conf文件中proxy_pass更改成可以访问的IP地址+端口就ok了。








鲁承星/Luke
互联网产品负责人/Leader
-----------------------------------------------------




微信 : 465608188
电话:13717825876
邮箱:[email protected]

你可能感兴趣的:(Development)