How to ensure nginx serves a request from an external IP?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-05-01T20:25:39Z Indexed on 2010/05/01 20:27 UTC
Read the original article Hit count: 149

Filed under:
|
|

I have a strange situation, where my nginx setup stopped handling external requests. I'm pretty stuck. If I hit the domain without a subdomain, I properly get redirected, however, if I request the full url, that fails and doesn't log anything, anywhere. I am able to curl localhost on the server itself, however when I attempt to curl from an external machine, it fails with:

curl: (7) couldn't connect to host

I've also noticed that bots can get through, I've seen Google hit the log every now and then.

My nginx.conf file:

upstream mongrels {
  server 127.0.0.1:5000;
}

server {
  listen 80;
  server_name culini.com;
  rewrite ^/(.*) http://www.culini.com/$1 permanent;
}

# the server directive is nginx's virtual host directive.
server {
  # port to listen on. Can also be set to an IP:PORT
  listen 80;

  # Set the max size for file uploads to 50Mb
  client_max_body_size 50M;

  # sets the domain[s] that this vhost server requests for
  server_name www.culini.com;

  # doc root
  root /var/www/culini/current/public;

  log_format app '$remote_addr - $remote_user [$time_local] '
                '"$request" $status  $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for" [$upstream_addr $upstream_response_time $upstream_status]';

  # vhost specific access log
  access_log  /var/www/culini/current/log/nginx.access.log  app;
  error_log  /var/www/culini/current/log/nginx.error.log  debug;
  location / {
    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_redirect false;
    proxy_max_temp_file_size 0;
    proxy_intercept_errors on;

    proxy_ignore_client_abort  on;

    if (-f $request_filename) {
      break;
    }

    if (!-f $request_filename) {
      proxy_pass http://mongrels;
      break;
    }
  }
}

Please, please, any help would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about nginx

Related posts about webserver