【问题标题】:Block other domains pointing to yours阻止指向您的其他域
【发布时间】:2019-03-21 00:56:34
【问题描述】:

我有域 abc.com,但我注意到另一个不属于我的域指向与我相同的 IP 地址。它是我的幻影,所以当您访问该网站时,它看起来就像您在我的网站上一样。

关于如何防止这种情况的任何想法?

我的虚拟主机看起来像:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName www.example.com
        DocumentRoot /path/to/site

        <Directory /path/to/site/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>


RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !example\.com [NC]
RewriteCond %{HTTP_HOST} !example.com [NC]
RewriteRule .? - [F]

ServerName example.com
ServerAlias www.example.com
</VirtualHost>
</IfModule>

【问题讨论】:

  • 您是否尝试使用 mod-rewrite 验证主机?
  • 这是什么意思?我没有,不知道怎么做!
  • 您的网站是如何配置的?
  • 在网络服务器配置中,您可以添加一个检查以阻止另一个域。这取决于您的配置的外观。
  • 为什么会被否决??我在这里寻找一个合法的答案

标签: linux apache mod-rewrite


【解决方案1】:

Apache 使用 HTTP 请求标头中的 Host 字段来了解请求的虚拟主机(Host 对应于 apache ServerNameServerAlias)。

试试apache2ctl -S,它会给你一个包含如下内容的输出:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server ip (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost ip (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost www.example1.com (/etc/apache2/sites-enabled/001-vhost.conf:1)
         port 80 namevhost www.example2.com (/etc/apache2/sites-enabled/002-vhost.conf:1)
*:443                  is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/default-ssl.conf:2)
         port 443 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/default-ssl.conf:2)
         port 443 namevhost www.example1.com (/etc/apache2/sites-enabled/non-default-ssl.conf:2)

现在假设我的 ip 是 1.1.1.1:

鉴于这三个curl 命令:

1. curl http://1.1.1.1 -H 'Host: www.example1.com'
1. curl http://1.1.1.1 -H 'Host: www.example2.com'
1. curl http://1.1.1.1 -H 'Host: www.spoofexample.com'

第一个,apache在vhost文件中找到对应的ServerName,使用/etc/apache2/sites-enabled/001-vhost.conf来满足请求

第二种,apache在vhost文件中找到对应的ServerName,使用/etc/apache2/sites-enabled/002-vhost.conf来满足请求

第三个(您不需要的映射 DNS),apache 没有在其任何 vhosts 文件中找到对应的 ServerName,并使用 /etc/apache2/sites-enabled/000-default.conf 来满足请求

同样的逻辑也适用于 SSL 虚拟主机。

PS1:默认 HTTP 虚拟主机的 ServerName 的值为 ip,默认 SSL 虚拟主机中没有 ServerName。 Apache 只是假设127.0.1.1,这不是它侦听的 IP 地址(只是告诉它不会更混乱)。

PS2:要使虚拟主机成为默认虚拟主机,它必须是按名称排序的第一个 (000 -> 001 -> 002)。

【讨论】:

    【解决方案2】:

    不可能有人可以伪造您的帐户。 假设我是 hostgator 的 abc.com 的域所有者。为了在godaddy.com上托管它,我必须去域控制器把godaddy名称服务器放在那里。然后在托管我创建一个同名的网站。 您也不应该使用 ipaddress 托管一个真实的域。始终使用名称服务器,这将阻止所有这些配置。 请检查此页面的重定向 https://www.namecheap.com/support/knowledgebase/article.aspx/385/2237/how-to-redirect-a-url-for-a-domain 您是从本地计算机托管域吗?

    【讨论】:

      猜你喜欢
      • 2011-10-03
      • 2014-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多