Weird problem

I’m setting up a new server, consolidating some smaller ones into the
new
one. I’ve installed nginx 0.7.38 and I’m using BIND as a nameserver. I
have
checked my domain.host files and they all look fine.

I’m moving domains a few at a time. As I move them I change the IP’s of
the
child nameservers to point to IP’s on the new server. This results in
fairly
quick propagation and within a short period if I flush my cache at my
home
PC I am directed to the new server.

I am using the same nginx.conf as I use elsewhere, except for the server
name and number of child processes. I use the same site config files. I
am
using the same paths. generally /home/jim/domain.tld/html for a document
root, and I am using the same version and configuration of php and
php-fpm
with the same user and group. The only difference in my nginx binary is
that
I have added support for h.264 streaming but I have removed that with
the
same results so I doubt that can be an issue.

The problem is that each time I add a domain for anywhere from 6-24
hours
nginx serves pages from a different domain on the new machine. Or
sometimes
it defaults to serving from /usr/local/nginx/html. I’ve confirmed the
paths
that it is calling “document root” and that the IP’s are from the new
server. After this amount of time nginx starts serving documents from
the
correct directory/doc root.

Any ideas?

Any parts of your nginx.conf?

Would you try this for vivid-tube.com?


location ~ .php$ {
root /home/jim/vivid-tube.com/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/jim/
vivid-tube.com/html$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}


On Mon, Mar 02, 2009 at 02:04:59AM -0500, Jim O. wrote:

sendfile        on;

gzip_types text/plain text/css application/x-javascript text/xml
}
fastcgi_pass 127.0.0.1:9000;
deny all;

server {
listen vivid-tube.com:80;

Try to set address here:
listen XX.XX.XX.XX:80;

I think that nginx’s host nameserver have cached an old vivid-tube.com
address and so nginx does not match a new address. Other way is wildcard

listen *:80;

or

listen 80;

}
BTW, it’s better to move this “if” in separate server:

server {
server_name vivid-tube.com *.vivid-tube.com;

}

server {
server_name www.vivid-tube.com;
rewrite ^ http://vivid-tube.com$request_uri? permanent;
}

Thanks Igor. Changing to

listen 80;

worked like a charm. I never had this problem with other servers. I’ve
been
pulling out my hair for a couple of days over this.

Jim

nginx.conf:

#user nginx;
worker_processes 8;

error_log logs/error.log;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
server_tokens off;

sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;

server_names_hash_bucket_size    64;

#keepalive_timeout  0;
keepalive_timeout  70 20;

gzip  on;
gzip_comp_level 1; gzip_proxied any;

gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript;

server {
    listen      *:80;
    server_name  mars.jlkhosting.com;


    location / {
        root   html;
        index  index.php index.html index.htm;
    }

    error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME 

/scripts$fastcgi_script_name;
include fastcgi_params;
}

location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
      expires max;
}

    location ~ /\.ht {
        deny  all;
    }
}

include /usr/local/nginx/sites-enabled/*;
include /usr/local/nginx/conf/fastcgi_params;
}

Typical site config:

server {
listen vivid-tube.com:80;
server_name vivid-tube.com *.vivid-tube.com;
index index.php index.html;
root /home/jim/vivid-tube.com/html;

location / {
error_page 404 = //index.php;

if ($host ~* www.(.)) {
set $host_without_www $1;
rewrite ^(.
)$ http://$host_without_www$1 permanent;
}

location ~ .flv$ {
flv;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
}
}

Currently that domain is pointing to nginx doc root and you can confirm
by
going to http://vivid-tube.com/phpinfo.php. You’ll see that the php
variable
“_SERVER[“SCRIPT_FILENAME”]” is “/usr/local/nginx/html/phpinfo.php”.
Earlier
that domain was pointing to another domain. Later it will point
(hopefully)
where it should…

I’ve reloaded and restarted nginx and even rebooted the server. No luck.

Jim

From: [email protected] [mailto:[email protected]] On Behalf Of
Joe
Sent: Monday, March 02, 2009 1:26 AM
To: [email protected]
Subject: Re: Weird problem

Any parts of your nginx.conf?
On Mon, Mar 2, 2009 at 9:25 AM, Jim O. [email protected]
wrote:
I’m setting up a new server, consolidating some smaller ones into the
new
one. I’ve installed nginx 0.7.38 and I’m using BIND as a nameserver. I
have
checked my domain.host files and they all look fine.

I’m moving domains a few at a time. As I move them I change the IP’s of
the
child nameservers to point to IP’s on the new server. This results in
fairly
quick propagation and within a short period if I flush my cache at my
home
PC I am directed to the new server.

I am using the same nginx.conf as I use elsewhere, except for the server
name and number of child processes. I use the same site config files. I
am
using the same paths… generally /home/jim/domain.tld/html for a document
root, and I am using the same version and configuration of php and
php-fpm
with the same user and group. The only difference in my nginx binary is
that
I have added support for h.264 streaming but I have removed that with
the
same results so I doubt that can be an issue.

The problem is that each time I add a domain for anywhere from 6-24
hours
nginx serves pages from a different domain on the new machine. Or
sometimes
it defaults to serving from /usr/local/nginx/html. I’ve confirmed the
paths
that it is calling “document root” and that the IP’s are from the new
server. After this amount of time nginx starts serving documents from
the
correct directory/doc root.

Any ideas?