Setting up nginx to support custom domain name
<p>I have a Django web application hosted on a VM with the Debian-based Ubuntu as the OS, and nginx reverse proxy + gunicorn as the webserver. </p>

<p>The DNS of this web application is <code>myapp.cloudapp.net</code>. I also have a ccTLD <code>mydomain.pk</code> I need to be configured as a custom domain name for this web application.</p>

<p>My original registrar only supported nameservers. Thus I made an account on dns.he.net (a free DNS hosting provider) to host my nameservers, and set up the CName for my machine.</p>

<p>My problem is that once I set up the CName to point to my web app's DNS, entering mydomain.pk in the browser merely shows me a generic <code>Welcome to ngnix!</code> page. Whereas, entering <code>myapp.cloudapp.net</code> (or <code>myapp.cloudapp.net:80</code>) in the browser correctly opens up the web application. Why isn't setting up the CName working? </p>

<p>I've talked to the support staff at dns.he.net - I've been told my CName is set up correctly, and that there might be some problem with my nginx configuration. </p>

<p>For instance, here's my <code>etc/nginx/sites-available/myproject</code> file:</p>

<pre><code>server {
    listen 80;
    server_name myapp.cloudapp.net;
    charset utf-8;
    underscores_in_headers on;
    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {

        root /home/myuser/projectpk/project;
    }

    location /static/admin {

        root /home/myuser/.virtualenvs/projectpk/local/lib/python2.7/site-packages/django/contrib/admin/static/;
    }

    location / {
        proxy_pass_request_headers on;
        proxy_buffering on;
        include proxy_params;
        proxy_pass          http://unix:/home/myuser/projectpk/project/project.sock;
    }


    error_page 500 502 503 504 /500.html;
    location = /500.html {
        root /home/myuser/projectpk/project/templates/;
    }
}
</code></pre>