• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

nginx fails to use a subdomain :(

#1
Hi.

Following issue: I have Ubuntu LTS and nginx and I want to have a subdomain ("new.domain.net"). On www.domain.net I have an old vBulletin 3.8 running which is intended to be replaced by XenForo, but I want to have a test installation of XenForo first to pull over the old data on new.domain.net.

I added an A record and a nginx config for it but it doesnt work, I'm always redirected to "www".

www.domain.net: works.
new.domain.net: redirection to www.
nww.domain.net: 404.

So I'd basically assume that DNS is propagated. It must be my configuration.

"www" config:

Code:
    server {
        listen       80;
        server_name  domain.net;
     
        root   /var/www/domain.net/public;
        index  index.html index.php;
     
        location ~ \.php$ {
            #root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_read_timeout  80;
            fastcgi_param  SCRIPT_FILENAME  /var/www/domain.net/public/$fastcgi_script_name;
            include        fastcgi_params;
        }
     
        # make system internal
        location /system {
            internal;
        }
     
        # client php-fpm
        location @php-fpm {
            internal;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_read_timeout  80;
            fastcgi_param  SCRIPT_FILENAME  /var/www/domain.net/public/$fastcgi_script_name;
            include        fastcgi_params;
        }
     
        location /system {
        }
    }
"new" config:

Code:
server {
         listen *:80;
         server_name new.domain.net;
         root /var/www/new-site;
     
        location /internal_data/ {
           internal;
        }
        location /library/ {
           internal;
        }
     
        index index.html index.htm index.php index.cgi index.pl index.xhtml;
     
         location / {
             try_files $uri $uri/ /index.php?$uri&$args;
         }
     
         location ~ \.php$ {
             fastcgi_pass    127.0.0.1:9000;
             fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
             include         fastcgi_params;
         }
    }
GoDaddy domain config:



Any clues?
 

MattW

Well-known member
#2
try removing the * on the listen?

EDIT: also, you should have a server_name for www as well, which you appear to be missing.