【问题标题】:django nginx gunicorn application showing apache2 default page - only on ip request not domain namedjango nginx gunicorn 应用程序显示 apache2 默认页面 - 仅在 ip 请求而不是域名
【发布时间】:2021-06-19 13:42:25
【问题描述】:

我的 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地址没有错误,也无法从域名得到响应,任何帮助将不胜感激,谢谢

【问题讨论】:

  • 您确定该域可能映射到 IP 吗?
  • @MohamedElKalioby pinging 它让我看到它不是正确的 ip,但是为什么我 sshing 到那个 ip,并且浏览器正在对在来自我一直用来测试它的 ip 的服务器?
  • 因为你用的是IP,所以没问题,问题是domain-ip映射问题。
  • @MohamedElKalioby 谢谢,我会联系我的托管服务支持团队并找到解决方案
  • @MohamedElKalioby 好的,所以我已经更新了我的跟踪记录以与新的 IP 地址内联,由于我最近从共享主机切换到 vps 出现了问题,但是按域访问了我的网站name 仍然没有响应,当 vps 上没有 apache2 时,访问 ip 地址时仍然存在 apache2 默认页面的问题

标签: django nginx gunicorn


【解决方案1】:

正如 Mohamed 在 cmets 部分所指出的,错误是由于我的域名托管服务 (godaddy) 中不一致的 A 记录值导致的不正确的 ip-domain 映射引起的

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

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

【讨论】:

    猜你喜欢
    • 2020-04-05
    • 1970-01-01
    • 2016-04-16
    • 2018-08-10
    • 1970-01-01
    • 2020-06-28
    • 2017-12-28
    • 2019-12-22
    • 2020-08-16
    相关资源
    最近更新 更多