Jenkins的安全防护
· 阅读需 2 分钟
图片与正文无关
在这篇文章中我们我们提到默认 Jenkins 是不提供任何权限控制的,但通过配置,可以增加用户名密码登陆机制。但更进一步的,我们不希望有人能够扫描到 Jenkins 的端口,通常默认是 8080,所以我的思路是使用 Apache 的反向代理配置,并且使用 HTTP BASIC AUTH 机制。
反向代理的配置如下:
<VirtualHost *:80>
ServerName your.domain.com
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ProxyRequests Off
ErrorLog logs/jenkins-error_log
CustomLog logs/jenkins-access_log common
<Location />
AuthUserFile /var/www/html/etc/htpasswd
AuthType Basic
AuthName "Jenkins"
Require valid-user
</Location>
</VirtualHost>
htpasswd 文件是通过 Apache 的 htpasswd 命令设置的。
但是启动之后发现输入了 BASIC AUTH 的用户名和密码之后,又弹出了 Jenkins 自己的 BASIC AUTH,通过 Google,找到如下解决方案,在 httpd.conf 里添加如下配置,这个依赖于 mod_headers 模块。
# remove auth from headers
RequestHeader unset Authorization