Bad Hostname Error?
Maxim Dounin
mdounin at mdounin.ru
Tue Dec 13 23:50:01 UTC 2011
Hello!
On Wed, Dec 14, 2011 at 12:54:28AM +0200, Cabbar Duzayak wrote:
> 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?
The message you've provided suggests it's from your browser
(proxy?), not from nginx.
> 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...
With such configuration nginx will only do a "localhost" name
lookup once during configuration parsing.
Maxim Dounin
More information about the nginx
mailing list