0

I'm trying to add a subdomain to my nginx server, and can't seem to get it working. Here's the config file for my primary server:

server {
            listen   80;
            server_name  www.kevin-whitaker.net;
            rewrite ^/(.*) http://kevin-whitaker.net permanent;
           }

server {
            listen   80;
            server_name  kevin-whitaker.net;

            access_log /home/admin/public_html/kevin-whitaker.net/log/access.log;
            error_log /home/admin/public_html/kevin-whitaker.net/log/error.log;

            root   /home/admin/public_html/kevin-whitaker.net/public/;
            index  index.html;

            location / {
                          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;
                          proxy_redirect false;

                          if (-f $request_filename/index.html) {
                                           rewrite (.*) $1/index.html break;
                          }

                          if (-f $request_filename.html) {
                                           rewrite (.*) $1.html break;
                          }

            }

}

And for the subdomain:

server {
            listen   80;
            server_name  www.pci.kevin-whitaker.net;
            rewrite ^/(.*) http://pci.kevin-whitaker.net permanent;
           }

server {
            listen   80;
            server_name  pci.kevin-whitaker.net;

            access_log /home/admin/public_html/pci.kevin-whitaker.net/log/access.log;
            error_log /home/admin/public_html/pci.kevin-whitaker.net/log/error.log;

            root   /home/admin/public_html/pci.kevin-whitaker.net/public/;
            index  index.html;

            location / {
                          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;
                          proxy_redirect false;

                          if (-f $request_filename/index.html) {
                                           rewrite (.*) $1/index.html break;
                          }

                          if (-f $request_filename.html) {
                                           rewrite (.*) $1.html break;
                          }

            }

}

The primary domain (kevin-whitaker.net) functions like it should. However, the subdomain is unresolved when I try to browse to or ping it. Is there some other step I'm missing?

3

If the domain names used above are the ones you are talking about then your subdomain may not be working because there is no DNS entry for them. Do a dig and look for answer section in the reply.

dig kevin-whitaker.net has a proper answer section where as dig pci.kevin-whitaker.net is missing the answer section. Just put the DNS entries and you would be good to go.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.