Report this

What is the reason for this report?

Django NGINX configuration with DNS

Posted on January 1, 2015

Hi,

I used the one click django install to create a droplet for my blog. I have succesfully gotten the site to run, and it loads well via the the IP Address (http://104.236.117.75/). However, when I use my domain name (johnpham.me), I get a Bad Request (400) error. I purchased the domain from namecheap and redirected it to use the DO nameservers. I set it to @ for the ip address. I was thinking it was a DNS propagation issue, but whois lookups for the domain shows the digitalocean nameservers. Pinging the domain name works. Domain lookups reveal the correct IP, but I still can’t visit the site from the domain name.

I’ve configured my allowed hosts [“*”] in settings.py to see if I can get anything to work. Here’s the relevant part of my NGINX settings: Could the root, index, upstream app server be the problem? Those don’t refer to anything that I’m currently using, but since it loads fine with the IP address I didn’t think I would need to delete it.

upstream app_server {
    server 127.0.0.1:9000 fail_timeout=0;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name johnpham.me;

    keepalive_timeout 5;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_pass http://app_server;
    }


Any help or insights would really be appreciated!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

For the records: Be sure about the configuration of allowed hosts in Django Settings!

I wasted some hours to figure out that I forgot to also add the domain name there, so:

ALLOWED_HOSTS = [server_ip, domain1.com, domain2.com]

Did you ever figure this out? I’m having the same issue

This comment has been deleted

The developer cloud

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

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.