Apache2基本authentication:user @ ip,user2 @ ip2 – 这可能吗?

我正在寻找客户在办公室远程办公时使用的外部服务。

假设:我的办公室IP和客户办公室IP都是静态的。

我希望允许我的客户访问服务,例如HTTP基本身份validation安全pipe理应用程序。

在Apache Basic Auth中有没有办法创build基于User @ IP的限制?

我想要:

  • 我@ my_office
  • 我@ my_home
  • client1 @ their_office1
  • client2 @ their_office2

为了testing,我尝试了这个代码:

<Location /> Satisfy All AuthType Basic AuthName "Authorisation" AuthUserFile /etc/apache2/passwd Order deny,allow Deny from all Allow from 10.0.0.1/32 Require user me Order deny,allow Deny from all Allow from 10.0.0.2/32 Require user client1 </Location> 

有没有一种使用Apache Basic Auth做这个的已知方法?

而且,不是从一个未知的IP接收到一个成功的用户/密码的“Forbidden”,是否可以请求Apache再次请求用户的详细信息?

如果您使用Apache httpd 2.4,则可以使用新的语法来完成此操作。

 <RequireAny> <RequireAll> Require IP 10.0.0.1/32 Require user me </RequireAll> <RequireAll> Require IP 10.0.0.2/32 Require user client1 </RequireAll> </RequireAny> 

如果没有自定义身份validation处理程序,这种事情在2.4之前是非常困难的。