Hi, My website has been down for 2 months, I’ve basically given up resolving this issue, I have been talking with DO support as well as posting on stackoverflow and nobody seems to be able to help me.
Setup: 1-click install of django, ubuntu, nginx
Issue: After setting up a domain, visiting that domain results in a 400 error. visiting the IP works with no problem. I purchased the domain using Google Domains and used the custom name server option and put:
ns1.digitalocean.com ns2.digitalocean.com ns3.digitalocean.com
In etc/nginx/sites-available/django I have:
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 cannablr.com www.cannablr.com;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/django/dealr/dealr/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/django/dealr/dealr/static;
}
location /favicon.ico {
alias /home/django/django/dealr/favicon.ico;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
I have this file symlinked inside etc/nginx/sites-enabled.
Another thing that may be worth noting is even though I get a 400 error when visiting the domain, it still loads the favicon.
Any ideas or help would be appreciated.
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.
i had the same problem but after following this instruction, …Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting…, its stopped overwriting as explained …thanks alot MeghaBodke
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
This has to do with getting ALLOWED_HOSTS correct. ALLOWED_HOSTS: A list of strings representing the host/domain names that this Django site can serve Ref: ALLOWED_HOSTS Correct this in your setting file. e.g. Django One-click app has settings location: /home/django/django_project/django_project/settings.py
ALLOWED_HOSTS = ['example.com']
# Discover our IP address
ALLOWED_HOSTS = ip_addresses()
Change “=” operator to “+=”, so that it will append ip addresses rather than overwriting ALLOWED_HOSTS setting.
# Discover our IP address
ALLOWED_HOSTS += ip_addresses()
Hi, did you find out the solution to this? I’m having the same problem.
Hi, did you find out the solution to this? I’m having the same problem.
Hi, did you find out the solution to this? I’m having the same problem.
OK, I think I’ve confirmed what I was hinting at.
here’s the headers when I curl by domain:
Now, when I go by IP:
These 2 look similar, but very different when you realize the Content-Type is different and the IP-based one sets a cookie.
The short answer is that you have 2 separate sites running on this thing.
Let’s run this to see if my theory pans out:
This comment has been deleted