为什么我在访问域时收到 400 Bad Request 错误?

Why am I getting a 400 Bad Request error when visiting domain?

我的网站已经宕机 2 个月了,我基本上已经放弃解决这个问题了,我一直在与 DO 支持人员交谈并在 Whosebug 上发帖,但似乎没有人能够帮助我。

设置:Digital Ocean 一键安装 django,ubuntu,nginx

问题:设置域后,访问该域会导致 400 错误。访问IP没有问题。我使用 Google 域购买了域并使用自定义名称服务器选项并输入:

ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com

在etc/nginx/sites-available/django我有:

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

我在 etc/nginx/sites-enabled.

中建立了这个文件的符号链接

另一件可能值得注意的事情是,即使我在访问域时遇到 400 错误,它仍然会加载网站图标。错误日志中没有错误(错误日志记录已配置)

如有任何想法或帮助,我们将不胜感激。

尝试添加这个ALLOWED_HOSTS = ("yourdomain.com",)