gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 21:15:16 25 4
gpt4 key购买 nike

我的网站已经宕机 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 中有这个文件的符号链接(symbolic link)。

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

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

最佳答案

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

关于nginx - 为什么我在访问域时收到 400 Bad Request 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31167940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com