-1

So, I run an authoritative DNS server using Bind.

I add subdomains frequently. For some reason, this time, the subdomain I added is pointing to domain.com and not subdomain.domain.com. I don't understand why this is happening.

I added a new A record to my DNS zonefile. It's pointing to the same IP address that all my other subdomains are pointing to. I incremented the serial number. I reloaded bind.

When I visit the subdomain.domain.com, I get whatever is located at domain.com. I've tried now with two subdomains. They are both pointing to domain.com. I've also checked the syslog file for any bind logs, but there are none.

I've changed absolutely nothing in the way that I do things so I'm dumbfounded as to why this is suddenly happening.

I'm relatively new to DNS. Any advice on how to proceed?

EDIT: Here is my nginx server block for the subdomain in question. As well as the nginz server block for the domain.

server {
    listen 80;
    server_name subdomain.domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    include /etc/nginx/ssl;
    include /etc/nginx/cert;

    server_name subdomain.domain.com;

    root /home/jasonaburton/deployments/subdomain/current/public;

    access_log /var/log/nginx/subdomain.domain.com.access.log;
    error_log /var/log/nginx/subdomain.domain.com.error.log;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    include /etc/nginx/gzip;

    location ~* \.php$ {
        fastcgi_pass    unix:/var/run/php5-fpm.sock;
        fastcgi_index   index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include         /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME     $document_root$fastcgi_script_name;
        fastcgi_param APP_ENV 'env';

        add_header X-Frame-Options "DENY";
        add_header X-Content-Type-Options "nosniff";
        add_header X-XSS-Protection "1; mode=block";
        add_header Cache-Control "no-cache, max-age=0, must-revalidate, no-store, private";
    }
}

server {
    listen 80;
    server_name domain.com www.domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 default_server;
    include /etc/nginx/ssl;
    include /etc/nginx/pulse-cert;

    server_name domain.com www.domain.com;

    root /home/jasonaburton/domain.com/current/web;

    access_log /var/log/nginx/www.domain.com.access.log;
    error_log /var/log/nginx/www.domain.com.error.log;

    index index.php;

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

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    include /etc/nginx/gzip;

    location ~* \.php$ {
        fastcgi_pass        unix:/var/run/php5-fpm.sock;
        fastcgi_index       index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        include             /etc/nginx/fastcgi_params;
        fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
add_header Cache-Control "no-cache, max-age=0, must-revalidate, no-store";
    }
}

Thanks, Jason

7
  • 1
    What is the record you created? Dec 12, 2016 at 22:24
  • 1
    If you query an independent third-party DNS server (e.g. Google), does it return the IP address you expect? For example, dig subdomain.domain.com. @8.8.8.8 A. Dec 12, 2016 at 22:25
  • yes, I just queried and it shows the IP address that I expect. I know it's pointing to the right IP address externally but there's something going on internally that is pointing that subdomain to the main domain. They both share the same IP Dec 12, 2016 at 22:27
  • 1
    OK, if they both have the same IP, then that's what you wanted? But then you say that "there's something going on internally that is pointing that subdomain to the main domain." But that's what you said you wanted! All the DNS records point to the same IP address. Dec 12, 2016 at 22:32
  • 1
    Sounds like problem is in the configuration of your web server. Are you using Apache? Nginx?
    – eltiare
    Dec 12, 2016 at 22:58

2 Answers 2

0

Try removing the text "default_server" from after the listen and restart nginx. If that doesn't break anything, but fixes the fault then great.

Something else to try - Have you reload/restarted nginx so that it sees the specific subdomain configuration file? Also, are the file permissions right on the file containing the subdomain configuration?

Check the file permissions, double check the file is in the right place etc, then reload nginx.

4
  • It's funny, I just tried reloading nginx, and it failed to load the configuration file. That is the issue. It hasn't loaded the most recent configuration change and therefore isn't finding the server block and instead loading the default_server. Now to figure out why it's failing... (Thanks!) Dec 13, 2016 at 16:39
  • File and directory permissions/ownership? Copy them from the default configuration.
    – bao7uo
    Dec 13, 2016 at 16:44
  • Are you using symlinks? If so make sure they aren't relative
    – bao7uo
    Dec 13, 2016 at 16:48
  • Found the error. when I run nginx -c /etc/nginx/nginx.conf -t, it says that the server_names_hash_max_size isn't large enough so I increased the length from 512 to 1024 and it works. Now, the only puzzle is why that was the error. My subdomain name is no longer than other subdomains I manage so why it would complain about the length going forward, I'm not sure. Dec 13, 2016 at 17:03
0

This will either be a redirect from the web page served by subdomain.domain.com which is taking you to domain.com, or an nginx server block configuration issue, where nginx is not configured to serve the content for subdomain.domain.com correctly.

Try:

grep -R default_server /etc/nginx/sites-enabled/

and:

grep -R server_name /etc/nginx/sites-enabled/

(amend the path according to your system) to help pinpoint the issue. default_server and server_name are relevant directives that should be in the config files.

6
  • I ran those two commands. The default server is www.domain.com and the server_name is in the list as subdomain.domain.com, just like I would expect. Dec 13, 2016 at 15:11
  • As well, I tested to see if I was being redirected by subdomain.domain.com to domain.com by modifying code in the subdomain directory, but that code was never hit, so it is not even going into that directory. It must be a nginx configuration issue, but I can't see how it would be, this whole process is scripted, so for it to suddenly not work for any new subdomains is odd. Dec 13, 2016 at 15:13
  • I was expecting it might say server_name subdomain.domain.com domain.com in the same line. That would cause the problem...
    – bao7uo
    Dec 13, 2016 at 15:19
  • I've just posted the server block for the subdomain in question. And no I did not see domain.com beside subdomain.domain.com in the server_name. Dec 13, 2016 at 15:24
  • @jasonaburton Can you post the default one as well?
    – bao7uo
    Dec 13, 2016 at 16:22

Not the answer you're looking for? Browse other questions tagged .