在我的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
文件中获取用户列表。
答案 0 :(得分: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>
答案 1 :(得分:0)
您可以创建两个vhost,一个侦听外部接口,另一个侦听本地。身份验证设置将在前者中。
答案 2 :(得分:0)
我认为David已经很好地介绍了Apache2配置,但使用拆分DNS为内部和外部用户提供不同的服务也很常见。您的内部用户确实没有理由从您的代理发出请求,因为他们(表面上)可以直接访问“端点”。
如果您的内部用户连接到您的某个公共IP地址,有些情况下您实际上可能会出现路由延迟和拥塞。最初,我是两个DNS服务器的独立硬件的粉丝,但最近切换到使用绑定“视图”为我的两个用户类提供不同的区域。