Reputation: 15804
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.
The DNS of this web application is myapp.cloudapp.net
. I also have a ccTLD mydomain.pk
I need to be configured as a custom domain name for this web application.
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.
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 Welcome to ngnix!
page. Whereas, entering myapp.cloudapp.net
(or myapp.cloudapp.net:80
) in the browser correctly opens up the web application. Why isn't setting up the CName working?
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.
For instance, here's my etc/nginx/sites-available/myproject
file:
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/;
}
}
Upvotes: 6
Views: 15653
Reputation: 5549
Remove the server_name
line, it's not needed in nginx unless you want to serve different content depending on the host name you receive.
If you remove that line, nginx will answer any request that arrives to your server at the proper port (80 in this case), coming with myapp.cloudapp.net
or mydomain.pk
in the Host
header.
This assumes that there is no other configuration in /etc/nginx/sites-enabled that would catch the requests.
Upvotes: 4