Weird problem

Jim Ohlstein jim.ohlstein at
Mon Mar 2 10:04:59 MSK 2009


#user nginx;
worker_processes  8;

error_log  logs/error.log;
pid        logs/;

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;

        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_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 {
server_name  *;
index index.php index.html;
root /home/jim/;

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

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

location ~ \.flv$ {

location ~ .php$ {
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 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.


From: owner-nginx at [mailto:owner-nginx at] On Behalf Of Joe
Sent: Monday, March 02, 2009 1:26 AM
To: nginx at
Subject: Re: Weird problem

Any parts of your nginx.conf?
On Mon, Mar 2, 2009 at 9:25 AM, Jim Ohlstein <jim.ohlstein at> 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 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?


More information about the nginx mailing list