如何限制 url 使用 apache 访问特定 IP?
How to restrict url access with apache to certain IP?
我在 ubuntu 上使用 apache2
,在 tomcat8
网络服务器前面。
我想将对 localhost/manager
的访问限制为仅特定的 IP 地址。
服务器在我的内网,ip是102.168.139.111
。我希望能够仅从我的本地计算机 192.168.128.222
访问 /manager
端点,而不是从其他任何地方。
但以下内容不起作用,我总是得到 403 Permission denied
。为什么?
apache2.conf
:
<Location /manager/*>
Order Allow,Deny
Deny from all
Allow from 192.168.128.197
</Location>
有:
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
旁注:取出 <Location...>
将允许按预期访问我的本地 IP。所以一般的服务器配置似乎没问题。仅仅限制是行不通的。
可能是语句顺序问题。以下作品(在根路径上):
<Location />
Order Deny,Allow
Deny from all
Allow from 192.168.
</Location>
我在 ubuntu 上使用 apache2
,在 tomcat8
网络服务器前面。
我想将对 localhost/manager
的访问限制为仅特定的 IP 地址。
服务器在我的内网,ip是102.168.139.111
。我希望能够仅从我的本地计算机 192.168.128.222
访问 /manager
端点,而不是从其他任何地方。
但以下内容不起作用,我总是得到 403 Permission denied
。为什么?
apache2.conf
:
<Location /manager/*>
Order Allow,Deny
Deny from all
Allow from 192.168.128.197
</Location>
有:
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
旁注:取出 <Location...>
将允许按预期访问我的本地 IP。所以一般的服务器配置似乎没问题。仅仅限制是行不通的。
可能是语句顺序问题。以下作品(在根路径上):
<Location />
Order Deny,Allow
Deny from all
Allow from 192.168.
</Location>