Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Having server with CentOS and Plesk. Installed nginx right how it's discribed here: http://gudym.net/plesk-nginx.html But now if i go to mysupermegasite.com I'm getting

502 Bad Gateway
nginx/0.8.55

This error seems to be because Apache doesn't respond to NginX. BUT if I get to mysupermegasite.com:8080 i see the correct page. So Apache seems to run fine at 8080-th port. And in that instruction Apache supposed to be at 8080-th! So this seems to be correct.

Also in

/var/www/vhosts/mysupermegasite.com/conf/nginx.conf I see:

  server {
  listen      80;
  server_name mysupermegasite.com www.mysupermegasite.com ;
  error_log /var/www/vhosts/mysupermegasite.com/statistics/logs/error_log.nginx warn;

  location / {
    proxy_pass  http://www.mysupermegasite.com:8080$request_uri;
    include  /etc/nginx/proxy.conf;
  }

  location ~*/w3tc/* {
    proxy_pass  http://www.mysupermegasite.com:8080$request_uri;
    include  /etc/nginx/proxy.conf;
  }

  location ~* ^.+\.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js|ico|swf)$ {
    root /var/www/vhosts/mysupermegasite.com/public_html;
    expires 7d;
  }
 }

So... as I understand this, it directs nginx to mysupermegasite.com:8080 to get the page from Apache.

Let's see the error log vi /var/www/vhosts/mysupermegasite.com/statistics/logs/error_log.nginx

2012/02/07 07:35:29 [error] 11758#0: *1 mysupermegasite.com could not be resolved (110: Operation timed out), client: 89.112.11.xx, server: mysupermegasite.com, request: "GET / HTTP/1.1", host: "mysupermegasite.com"

Okay, it can't resolve this domain. Buy why? I even added

127.0.0.1 mysupermegasite.com

to the /etc/hosts file

If I try

wget mysupermegasite.com:8080

it downloads the page. But why NginX can't resolve this host?

What's wrong? Where to look for the reason?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Seems that your system can't resolve this domain. nginx doesn't use /etc/hosts file to resolve domains. Check that /etc/resolv.conf contains correct nameservers. I suggest you to explicitly specify IP address or localhost:

location / {
    proxy_pass http://localhost:8080;
}

Or you can specify better resolver for nginx, that knows this domain, instead of resolvers from /etc/resolv.conf:

resolver 192.0.2.1;

You can check if resolver knows the domain:

# dig mysupermegasite.com @192.0.2.1
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.