Hi,all
Pardon please,I’m not an English native speaker.So,I may make mistake in
grammar.
I have 4 IP address on my ubuntu server computer.For the convenience to
ditinguish them ,I name them as IP-1,IP-2,IP-3 and IP-4.
Now,I configure 3 virtual servers on nginx.The key content of
configuration is following.
#upstream
upstream my_upstream{
server IP-3:8080;
server IP-4:8080;
}
#the first server
server {
listen IP-1:80;
location / {
index index.php;
root /usr/share/nginx/www;
}
location ~.*.(php|php5)$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
#the second server
server {
listen IP-2:80;
location / {
index index.php;
root /usr/share/nginx/www;
}
location ~.*.(php|php5)$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
#the third server
server {
listen IP-3:80;
location / {
proxy_pass http://my_upstream;
}
location ~.*.(php|php5)$ {
root /usr/share/nginx/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
########################################################
In my opinion,those 3 virtual servers can wholely work right.But I met a
very surprising problem:the 1st and 2nd server can work
right,nevertheless,the third virtual server can not access.I look over
nginx.conf,and never find out any configuration mistake.Then,I change
the 3rd server’s LISTEN IP address IP-3 to IP-2,and change the 2nd
server’s LISTEN IP address IP-2 to IP-3.Oh my god,the 2nd server can not
access,but the 3rd can.I just exchange their LISTEN IP address.If you
have understood my problem description,would you please give me some
good suggestion?
Thanks!
I have ever guess that IP-3:80 is not listened by nginx.But when I run
“netstat -antup” in command line of shell,the result following tell me
that I guess wrong.
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
tcp 0 0 IP-3:80 0.0.0.0:* LISTEN
7346/nginx
tcp 0 0 IP-2:80 0.0.0.0:* LISTEN
7346/nginx
tcp 0 0 IP-2:80 0.0.0.0:* LISTEN
7346/nginx
Pardon
##############################################
I have ever guess that IP-3:80 is not listened by nginx.But when I run
“netstat -antup” in command line of shell,the result following tell me
that I guess wrong.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program
name
tcp 0 0 IP-3:80 0.0.0.0:* LISTEN 7346/nginx
tcp 0 0 IP-2:80 0.0.0.0:* LISTEN 7346/nginx
tcp 0 0 IP-1:80 0.0.0.0:* LISTEN 7346/nginx
Thank you,Maxim D…
I also think that the problem is outside of nginx.But I’m confused why
IP-1 and IP-2 work,IP-3 don’t.
On my computer,IP-1:8080,IP-2:8080,IP-3:8080 and IP-4:8080 are LISTENED
by tomcat application server.
I can access my tomcat by the whole IP address.It looks like a
contradiction that I can access tomcat via IP-3:8080,
and I can not access nginx via IP-3:80.It’s very terrible!
On Tue, Jul 26, 2011 at 10:06:12PM -0400, debugger87 wrote:
Hi,all
Pardon please,I’m not an English native speaker.So,I may make mistake in
grammar.
I have 4 IP address on my ubuntu server computer.For the convenience to
ditinguish them ,I name them as IP-1,IP-2,IP-3 and IP-4.
Now,I configure 3 virtual servers on nginx.The key content of
configuration is following.
[…]
In my opinion,those 3 virtual servers can wholely work right.But I met a
very surprising problem:the 1st and 2nd server can work
right,nevertheless,the third virtual server can not access.I look over
nginx.conf,and never find out any configuration mistake.Then,I change
the 3rd server’s LISTEN IP address IP-3 to IP-2,and change the 2nd
server’s LISTEN IP address IP-2 to IP-3.Oh my god,the 2nd server can not
access,but the 3rd can.I just exchange their LISTEN IP address.If you
have understood my problem description,would you please give me some
good suggestion?
From your description it looks like the problem lies somewhere
outside of nginx, e.g. your firewall preventing you from accessing
IP-3.
Thanks,Igor.
I have changed the configuration file nginx.conf as what you say.
Things go athwart,the 3rd server doesn’t work as before.
To describe my problem more definetely,I will give more information as
following.
IP-1:80 <=====> 1st server IP-1:8080 <=========>tomcat both work
right
IP-2:80 <=====> 2nd server IP-2:8080 <=========>tomcat both work
right
IP-3:80 <=====> 3rd server IP-3:8080 <=========>tomcat I can
access tomcat by IP-3:8080,but can not access nginx by IP-3:80.
Then,I try another configuration
IP-1:80 <=====> 1st server IP-1:8080 <=========>tomcat both work
right
IP-3:80 <=====> 2nd server IP-2:8080 <=========>tomcat I can
access tomcat by IP-2:8080,but can not access nginx by IP-3:80.
IP-2:80 <=====> 3rd server IP-3:8080 <=========>tomcat both work
right
In my eyes,my nginx configuration is correct.But the IP address IP-3
looks like very special.It can work for tomcat,but nginx not.
Have you ever met that strange problem?I’m struglling to sovle that
problem.
It’s pleasure to wait for your reply.
Thanks!
On Wed, Jul 27, 2011 at 04:58:14AM -0400, debugger87 wrote:
Thank you,Maxim D…
I also think that the problem is outside of nginx.But I’m confused why
IP-1 and IP-2 work,IP-3 don’t.
On my computer,IP-1:8080,IP-2:8080,IP-3:8080 and IP-4:8080 are LISTENED
by tomcat application server.
I can access my tomcat by the whole IP address.It looks like a
contradiction that I can access tomcat via IP-3:8080,
and I can not access nginx via IP-3:80.It’s very terrible!
Probably you need to add tomcat server name in Host header:
On Wed, Jul 27, 2011 at 04:58:14AM -0400, debugger87 wrote:
Thank you,Maxim D…
I also think that the problem is outside of nginx.But I’m confused why
IP-1 and IP-2 work,IP-3 don’t.
On my computer,IP-1:8080,IP-2:8080,IP-3:8080 and IP-4:8080 are LISTENED
by tomcat application server.
I can access my tomcat by the whole IP address.It looks like a
contradiction that I can access tomcat via IP-3:8080,
and I can not access nginx via IP-3:80.It’s very terrible!
Try setting something else to listen on IP-3:80 (e.g. “nc -l IP-3 80”)
and check if you are able to reach it.
Thank you,Maxim D…
I check the IP-3:80 in something else(e.g. apache2),and I found that I
can not reach the apache2 via IP-3:80.
Obviously,the true problem lies in the special IP address IP-3.So,I
should not spend more time in nginx configuration.
Any way ,thanks for your reply.
With best wishes.
On Wed, Jul 27, 2011 at 06:03:59AM -0400, debugger87 wrote:
by tomcat application server.
location / {
IP-1:80 <=====> 1st server IP-1:8080 <=========>tomcat both work
access tomcat by IP-2:8080,but can not access nginx by IP-3:80.
IP-2:80 <=====> 3rd server IP-3:8080 <=========>tomcat both work
right
In my eyes,my nginx configuration is correct.But the IP address IP-3
looks like very special.It can work for tomcat,but nginx not.
Have you ever met that strange problem?I’m struglling to sovle that
problem.
It’s pleasure to wait for your reply.
Thanks!