django nginx gunicorn 应用程序显示 apache2 默认页面 - 仅在 ip 请求上而不是域名

django nginx gunicorn application showing apache2 default page - only on ip request not domain name

来自我的 Ubuntu 18.04 LTS 服务器的非常奇怪的行为

我已经按照本教程学习了 here(两次),除了一些奇怪的事情外,一切正常

首先,当我使用浏览器访问我的VPS的IP时,django默认应用程序页面在整个教程中显示,但是通过域名访问它会导致超时错误

其次,既然我已经完成了教程并将 nginx 配置为代理传递给 gunicorn,现在显示 apache2 ubuntu 默认页面而不是访问 ip 地址时的 django 默认页面并且仍然域名无响应,即使此服务器上没有安装apache2...

$ whereis apache2
apache2:

这是我的 gunicorn.socket 文件

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

这是我的 gunicorn.service 文件

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=trends
Group=www-data
WorkingDirectory=/trends_dir
ExecStart=/trends_dir/trendsvenv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          trends.wsgi:application

[Install]
WantedBy=multi-user.target

这是我的 /etc/nginx/sites-available 站点配置文件,已正确链接到 /etc/nginx/sites-enabled

server {
    listen 80;
    server_name www.trendsontheblock.com trendsontheblock.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /trends_dir;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

如我所说,IP地址没有错误,域名也无法得到响应,将不胜感激,谢谢

正如 Mohamed 在评论部分指出的那样,错误是由于我的域名托管服务 (godaddy) 中的 A 记录值不一致导致的 ip 域映射不正确

这是因为我已从共享主机切换到 VPS,因此域名的名称服务器值变得不一致

需要将域名服务器重置为默认主机值,它的 A 记录已更新为新的 VPS 服务器 IP 这已解决我的问题