在将任何请求传递到端点之前添加或覆盖Authorization标头.授权标头可以是硬编码的,它只是字符串"username:password"的base-64编码(不带引号).
如果尚未完成,请启用mod_headers模块.
RequestHeader set Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="
要有条件地执行此操作,请启用mod_setenvif,例如,在本地请求的情况下仍然要求输入主密码:
SetEnvIf Remote_Addr "127\.0\.0\.1" localrequest RequestHeader set Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" env=!localrequest
http://en.wikipedia.org/wiki/Basic_access_authentication
http://httpd.apache.org/docs/2.0/mod/mod_headers.html
http://httpd.apache.org/docs/2.0/mod/mod_setenvif.html
例
# ALL remote users ALWAYS authenticate against reverse proxy's # /www/conf/passwords database #AuthBasicProvider /www/conf/passwords AuthType Basic AuthName "Protected Area" Require valid-user # reverse proxy authenticates against master server as: # Aladdin:open sesame (Base64 encoded) # RequestHeader set Authorization "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="