Report this

What is the reason for this report?

Configure subdomain on Centos with NGINX

Posted on April 8, 2014

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;
                      }

        }

}

What I would like now is to create a subdomain as following:

ArtWorked // DevCloud

server { server_name devcloud.artworked.com; root /usr/share/nginx/html/server/devcloud; }

Where I’m I going wrong ?

And does creating a subdomain on Nginx requires DNS intry such as an A record or a CNAME as there is conflicting information online.

Thanks for your help.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.