网站响应 IP,但不响应域名

网站响应 IP,但不响应域名

我已经在 AWS Lightsail Ubuntu 20.04 实例上托管了一个基于 Django 的网站,该网站在 Apache2 上运行。

使用 IP 18.133.43.205 时可以访问该网站。但是当我尝试使用域名 roosta.xyz 搜索我的网站时,连接超时。

DNS 使用 AWS 的名称服务器。我不认为 DNS 是问题所在,因为当我进行 whois 查询时,它会显示 AWS 名称服务器,当我在 Linux 终端中运行 dig roosta.xyz 时,会返回正确的 IP。

几天前,我收到了服务器的响应,但它要求使用 https,但我没有 SSL 证书,所以我的浏览器崩溃了。我不想使用 https。但在干预服务器并试图阻止它使用 https 之后,我现在又回到了连接超时的情况。

另一件事是,我在自己的机器终端上运行了 curl roosta.xyz,它返回了网页的 html?那么 chrome 怎么没有得到它呢?!

这是 apache 虚拟主机配置文件的副本:

<VirtualHost *:80>
    ServerName www.roosta.xyz
    ServerAdmin webmaster@localhost
    ServerAlias roosta.xyz
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /static /home/ubuntu/myWebsite/static
    <Directory /home/ubuntu/myWebsite/static>
        Require all granted
    </Directory>

    <Directory /home/ubuntu/myWebsite/myWebsite>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

    WSGIScriptAlias / /home/ubuntu/myWebsite/myWebsite/wsgi.py
    WSGIDaemonProcess myWebsite_app python-path=/home/ubuntu/myWebsite python-home=/home/ubuntu/myWebsite/venv
    WSGIProcessGroup myWebsite_app 
</VirtualHost>

Apache2ctl -S

VirtualHost configuration:
*:80                   roosta.xyz (/etc/apache2/sites-enabled/myWebsite.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

在网上搜索了几个小时后,我完全被难住了。我非常乐意提供更多相关代码或光帆设置图片来帮助解决我的问题。

答案1

  1. 问题的根源在于您的服务器没有响应 HTTPS。
    (例如:在 TCP 端口 443 上根本没有响应。我的连接尝试不得不超时,因为您的服务器甚至没有返回“连接被拒绝”数据包。这通常是 DROP 而不是 REJECT 防火墙策略的效果)。

  2. 另一方面,Chrome 拒绝通过纯 HTTP 进行连接,因为它确定HSTS 政策 您的域名不允许这样做。由于该政策,Chrome 会调整所有http://www.roosta.xyzURL,并将更改httphttpsURL。

要从 Chrome 测试 HSTS 策略:获取chrome://net-internals/#hsts

HSTS 检查 frosts.xyz

您的域名是预加载的 HSTS 列表的一部分(可能提交于https://hstspreload.org/
看:https://source.chromium.org/chromium/chromium/src/+/master:net/http/transport_security_state_static.json

要解决这个问题,您需要将您的域名从 HSTS pe-load 列表中删除(短期内不会发生),或者您需要设置 TLS 以便您的网站通过 https 出现。

相关内容