我想为在Ubuntu服务器12.04.1上运行的Apache的反向代理站点添加基本身份验证。
Web应用程序是Jenkins,它在Java EE容器上运行。
我在 httpd.conf ,
中添加了以下配置ProxyPass /jenkins/ http://localhost:8080/jenkins/¬
ProxyPassReverse /jenkins/ http://localhost:8080/jenkins/¬
ProxyRequests Off¬
ProxyPreserveHost On¬
¬
<Proxy http://localhost:8080/jenkins*>¬
Order deny,allow¬
Deny from all¬
▸ AllowOverride AuthConfig¬
▸ AuthType Basic¬
AuthName "jenkins"¬
▸ AuthBasicProvider file¬
AuthUserFile /etc/apache2/passfile¬
▸ Require valid-user¬
▸ Satisfy any¬
</Proxy>
当我使用错误的密码或不存在的用户名进行身份验证时,我可以在apache的 error.log 中找到以下消息,
[星期六10月27日17:51:59] [错误] [客户端222.128.175.95]用户kane: “/ jenkins /”的身份验证失败:密码不匹配[10月27号星期六 2012年17:52:04] [错误] [客户端222.128.175.95]用户阿拉丁未找到: /詹金斯/
在 passfile 中使用正确的用户和密码时,不会记录任何消息。虽然我在网络浏览器中输入了正确的用户和密码,但验证对话框会再次提示。 我还在apache的 access.log 中找到了以下输出,
222.128.175.95 - kane [27 / Oct / 2012:17:39:54 +0800]“GET / jenkins / HTTP / 1.1”401 794“ - ”“Mozilla / 5.0(Macintosh; Intel Mac OS X 10_8_2) AppleWebKit / 537.4(KHTML,与Gecko一样)Chrome / 22.0.1229.94 Safari浏览器/ 537.4"
有人知道如何让它发挥作用吗?感谢。
答案 0 :(得分:4)
您是否也在Jenkins上启用了身份验证?有关设置此信息的说明,请参阅此链接:https://wiki.jenkins-ci.org/display/JENKINS/Apache+frontend+for+security。
特别要注意的是,在Jenkins和Apache同时启用安全性的行,因为两者会发生冲突,导致您看到的无限提示。不幸的是你必须选择其中一个。
另请参阅此链接以获取有关Apache + Jenkins设置的更一般性讨论:https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Apache
答案 1 :(得分:1)
试试这个配置
ProxyPass /jenkins/ http://localhost:8080/jenkins/
ProxyPassReverse /jenkins/ http://localhost:8080/jenkins/
ProxyRequests Off
ProxyPreserveHost On
<Proxy http://localhost:8080/jenkins*>
AllowOverride None
Order allow,deny
allow from all
AuthName "jenkins"
AuthBasicProvider file
AuthType basic
AuthUserFile /etc/apache2/passfile
<Limit GET POST>
require valid-user
</Limit>
Satisfy all
</Proxy>