Bad Hostname Error?

Cabbar Duzayak cabbar at gmail.com
Tue Dec 13 22:54:28 UTC 2011


Hi everyone,

Every once in a while, requests to my NGINX server are giving 500
errors as with bad hostname responses for http://:

Can't connect to sub.mydomain.com:80 (Bad hostname: sub.mydomain.com)

It turned out to be an issue with the DNS server, i.e. my ubuntu box
is failing to resolve this sub.mydomain.com address.

What I don't understand is that why is NGINX making an ns lookup for
these requests??? Basically, when I make a request to this subdomain,
it should be resolving the request using the request header and proxy
it to localhost:81 or serving from local directory. And, I don't see
any reason to perform an nslookup here?

My config file is as follows:

server {
        listen   80;
        listen   [::]:80 default ipv6only=on; ## listen for ipv6

        server_name  sub.mydomain.com;
        server_tokens off;

        access_log  /var/log/nginx/access.log;
        error_log  /var/log/nginx/error.log info;

        location / {
                proxy_pass              http://localhost:81;
                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;
        }

        location /html {
                alias /home/user/html/
                expires max;
        }
}

DNS lookups will slow the server down, and trying to understand what
is going on here
Thanks...



More information about the nginx mailing list