【问题标题】:Why am I getting a 400 Bad Request error when visiting domain?为什么我在访问域时收到 400 Bad Request 错误?
【发布时间】:2015-09-19 00:01:42
【问题描述】:

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

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

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

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 错误,它仍然会加载网站图标。错误日志中没有错误(配置了错误日志)

任何想法或帮助将不胜感激。

【问题讨论】:

标签: nginx dns


【解决方案1】:

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

【讨论】:

  • “你的域名”后面需要逗号吗?
  • 我不敢相信就是这样。现在可以了,非常感谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-27
  • 1970-01-01
  • 1970-01-01
  • 2022-01-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多