在OpenLiteSpeed上允许/拒绝IP

时间:2019-08-01 00:13:11

标签: litespeed

我只想允许127.0.0.1/localhost/0.0.0.0,但是我尝试使用访问控制和.htaccess

order deny, allow 

deny from all 

allow from 127.0.0.1

它不起作用!

1 个答案:

答案 0 :(得分:0)

该拒绝允许规则在OpenLiteSpeed中不起作用。

对于访问控制,请确保您有一个空的服务器级别访问控制列表,并且vhost级别不会覆盖它。

[root@test ~]# cat /etc/hosts
127.0.0.1 mask.domain

[root@test ~]# curl -I -XGET http://mask.domain
HTTP/1.1 200 OK
Etag: "5-5d42a8ce-e18f0;;;"
Last-Modified: Thu, 01 Aug 2019 08:54:38 GMT
Content-Type: text/html
Content-Length: 5
Accept-Ranges: bytes
Date: Thu, 01 Aug 2019 08:58:50 GMT
Server: LiteSpeed
Connection: Keep-Alive

[root@test ~]# echo "123.456.789.000 mask.domain" > /etc/hosts
[root@test ~]# curl -I -XGET http://mask.domain
HTTP/1.1 403 Forbidden
Content-Type: text/html
Cache-Control: private, no-cache, max-age=0
Pragma: no-cache
Content-Length: 1139
Date: Thu, 01 Aug 2019 08:59:14 GMT
Server: LiteSpeed
Connection: Keep-Alive

访问控制对我有效,当我使用hosts文件将其设置为127.0.0.1-domain时,它为200 OK,而当我使用公共IP对其进行设置时,它变为403错误。

替代方式:

使用重写规则,如下所示:

RewriteEngine On

RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1

RewriteRule .* - [F]

如果要使用重写规则,请确保在更改规则后已重新启动OpenLiteSpeed。

最诚挚的问候,

相关问题