1

在我的 Apache 2 配置中,我有一个VirtualHost看起来像这样的:

<VirtualHost *:80>
  ServerName sub.domain.com

  # username:password sent on to endpoint
  RequestHeader set Authorization "Basic dXNlcm5hbWU6cGFzc3dvcmQ=="

  ProxyPass        /xyz http://192.168.1.253:8080/endpoint
  ProxyPassReverse /xyz http://192.168.1.253:8080/endpoint

  <Location /xyz>
    # This needs to let users through under the following circumstances
    #   * They are in 192.168.1.0/24
    #   * They have a valid user in a htpasswd file

    # So what goes here?
  </Location>
</VirtualHost>

我使用虚拟主机作为网络上另一台服务器(我将称之为端点)的反向代理。

我正在尝试找出一种配置,该配置将允许网络浏览中的用户sub.domain.com自动获得端点服务。但是,应提示网络外的用户输入凭据

端点需要我使用 RequestHeader (我想要的)隐藏的密码。应提示外部用户的密码是不同的,并且需要是 BasicAuth,从htpasswd文件中获取它的用户列表。

4

3 回答 3

6
<Location /xyz>
  # This needs to let users through under the following circumstances
  #   * They are in 192.168.1.0/24
  #   * They have a valid user in a htpasswd file

http://httpd.apache.org/docs/2.2/mod/core.html#satisfy出来:

  Require valid-user
  Order allow,deny
  Allow from 192.168.1
  Satisfy any

当然,您还需要包含您的 AuthUserFile 或任何指令

  AuthType basic
  AuthName "yadayadayada"
  AuthUserFile /foo/bar/blah/.htpasswd
</Location>
于 2009-02-24T00:54:21.250 回答
0

您可以创建两个虚拟主机,一个在外部接口上侦听,一个在本地。身份验证设置将在前者中。

于 2009-02-24T00:55:57.737 回答
0

我认为 David 已经很好地介绍了 Apache2 配置,但使用拆分 DNS 为您的内部和外部用户提供不同的服务也很常见。您的内部用户确实没有理由从您的代理发出请求,因为他们(表面上)可以直接访问“端点”。

在某些情况下,如果您的内部用户连接到您的公共 IP 地址之一,您实际上可能会导致路由延迟和拥塞。最初,我喜欢为两个 DNS 服务器使用单独的硬件,但最近转而使用绑定“视图”为我的两个用户类提供不同的区域。

于 2009-02-24T01:48:02.540 回答