Apache:通过IP(HTTP/HTTPS)限制对Web服务器的访问

Apache:通过IP(HTTP/HTTPS)限制对Web服务器的访问,apache,ip,lets-encrypt,restriction,Apache,Ip,Lets Encrypt,Restriction,我在VPS上运行一个网站,我想完全阻止通过VPS IP地址访问该网站。 我让它为HTTP工作,但它似乎不可能为HTTPS。 我所做的: <VirtualHost *:80> ServerName xxx.xxx.xxx.xxx Redirect 403 / DocumentRoot /a/folder/here/ </VirtualHost> 服务器名xxx.xxx.xxx.xxx 重定向403/ DocumentRoot/a/文件夹/此处/ 这与预期的效果完全一样

我在VPS上运行一个网站,我想完全阻止通过VPS IP地址访问该网站。 我让它为HTTP工作,但它似乎不可能为HTTPS。 我所做的:

<VirtualHost *:80>
ServerName xxx.xxx.xxx.xxx
Redirect 403 /
DocumentRoot /a/folder/here/
</VirtualHost>

服务器名xxx.xxx.xxx.xxx
重定向403/
DocumentRoot/a/文件夹/此处/
这与预期的效果完全一样

但是我找不到一种方法为我的孩子做同样的事情

有人能帮我吗

**我正在使用:**

勒森密码证书


Apache 2.4只需对绑定到端口443的虚拟主机执行相同的操作:

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerName xxx.xxx.xxx.xxx
        Redirect 403 /
        DocumentRoot /a/folder/here/
    </VirtualHost>
</IfModule>

服务器名xxx.xxx.xxx.xxx
重定向403/
DocumentRoot/a/文件夹/此处/

只需对绑定到端口443的虚拟主机执行相同的操作:

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerName xxx.xxx.xxx.xxx
        Redirect 403 /
        DocumentRoot /a/folder/here/
    </VirtualHost>
</IfModule>

服务器名xxx.xxx.xxx.xxx
重定向403/
DocumentRoot/a/文件夹/此处/

注意:包含此规则的文件必须在使用SSL的其他站点之后执行

例如:

0-site1.conf=未使用ssl的网站(端口80)

0-site1-ssl.conf=使用ssl的网站(端口443)

1-direct-access-conf=包含以下内容的文件:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName xxx.xxx.xxx.xxx
    Redirect 403 /
    DocumentRoot /a/folder/here/
</VirtualHost>
</IfModule>

服务器名xxx.xxx.xxx.xxx
重定向403/
DocumentRoot/a/文件夹/此处/

注意:包含此规则的文件必须在使用SSL的其他站点之后执行

例如:

0-site1.conf=未使用ssl的网站(端口80)

0-site1-ssl.conf=使用ssl的网站(端口443)

1-direct-access-conf=包含以下内容的文件:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName xxx.xxx.xxx.xxx
    Redirect 403 /
    DocumentRoot /a/folder/here/
</VirtualHost>
</IfModule>

服务器名xxx.xxx.xxx.xxx
重定向403/
DocumentRoot/a/文件夹/此处/

我没有想到IfModule谢谢。我没有想到IfModule谢谢。