Apache的基本authentication – auth不需要一些文件

我试图允许对Nagios安装中某些脚本的未经validation的访问。 虽然这个问题并不是关于Nagios,也不是CGI的处理,下面还要说明。

本质上,我想要在特定目录中的任何东西进行身份validation

http://example.com/nagios/cgi-bin/.... 

除了2个特定的path:

 http://example.com/nagios/cgi-bin/avail.cgi.... http://example.com/nagios/cgi-bin/trends.cgi.... 

目前,我已经设置了Apache来要求所有访问http://example.com/nagios/cgi-bin的authentication

 ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin <Directory "/usr/local/nagios/sbin"> Options ExecCGI AllowOverride None Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </Directory> 

我不希望复制在不同的目录中的脚本,因为这是打包软件,我想尽量减less支持 – 我不确定包内的URL使用规范path。

编辑:

我可以使用FilesMatch而不是Direcory块吗? 如果是这样,是基于PCRE或POSIX的Apache正则expression式?

编辑3:

运用

 <FilesMatch "/(cgi-bin\/)(?!trends.cgi)(?!avail.cgi)/"> 

从dir中的所有url中删除身份validation:(

我也尝试复制不同目录中的avail.cgi和trends.cgi脚本。 这似乎工作 – 但forms不填充我的Nagiosconfiguration的任何数据! 看起来,Nagios代码中内置了一个额外的authentication层。 这也将打败“要求任何/允许从IP”的方法。 🙁

虽然MSIE中的修改后的行为可能是正确的, 但这会导致我可怕的头痛!

你有没有尝试创build一个新的文件夹与您的“打开”CGI的符号链接?

如果服务器上有可用的第二个IP地址,则可以尝试在此IP地址上运行反向代理,该代理只转发这两个位置并执行HTTP身份validation。

 <VirtualHost secondIP:80> ProxyPassMatch ^\/nagios\/cgi-bin\/(trends|avail)\.cgi$ "http://127.0.0.1/nagios/cgi-bin/" ProxyPassReverse /nagios/cgi-bin/ "http://127.0.0.1/nagios/cgi-bin/" </VirtualHost> 

我还没有尝试过,如果这个工作正常,因为在Apache中没有ProxyPassReverseMatch指令。

使用满意:

 Require valid-user Order allow,deny Allow from IP Satisfy Any 

http://httpd.apache.org/docs/current/mod/core.html#satisfy

以下configuration对我来说需要validation单个CGI脚本:

 <Directory "/var/www/cgi-bin"> <Files "my-cgi-script"> # ... # AuthName, AuthType, AuthUserFile, Require # ... </Files> </Directory> 

尝试将FilesMatch嵌套到目录中,并在FilesPath指令中使用相对path。