脚本头过早结束:CGI、Nagios、LDAP

2024-08-23php开发问题
4

本文介绍了脚本头过早结束:CGI、Nagios、LDAP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我为 LDAPS 身份验证设置了 Nagvis 和 Nagios.我在 Nagvis 中有一个监控点(链接),它将我带到 Nagios Core 中的服务信息.当我单击 Nagvis 中的链接以访问 Nagios 时,我收到以下错误:/var/log/httpd24/error_log:

[cgi:error] [pid 25523] [client 155.157.39.194:23160] 脚本头过早结束:status.cgi,引用者:https://[EM Server FQDN]/nagios/cgi-bin/status.cgi?host=all

当我进入下一页时,我遇到了一个内部服务器错误页面,它只是告诉我查阅错误日志.点击浏览器上的 F5 或后退导航按钮可解决此问题.当我将 LDAPS 身份验证替换为基本身份验证时,不会出现任何问题.

我的 CGI 文件具有适当的权限.在 LDAP 身份验证过程中一定有什么东西丢失了?

感谢任何帮助!附上我的nagios.conf...

 ScriptAlias/nagios/cgi-bin "/usr/local/nagios/sbin"<目录/usr/local/nagios/sbin">SSL要求SSL选项 ExecCGIAllowOverride AuthConfig订单拒绝,允许拒绝一切# 限制 HTTP 方法<LimitExcept GET POST OPTIONS>要求全部拒绝</限制例外>允许来自<允许主机的 IP 子网>开会SessionCookieName httpd_nagsess 路径=/会话最大年龄 1800SessionCryptoPassphrase <模糊>错误文档 401/auth/login.htmlAuthFormProvider ldapAuthType 表单AuthLDAPGroupAttributeIsDN 开启AuthName通过 Active Directory (LDAPS) 登录 Nagios"AuthLDAPURL "ldaps://<域控制器#1 FQDN>:3269 <域控制器#2 FQDN>:3269/DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>?sAMAccountName?sub?(objectClass=*)"没有任何AuthLDAPBindDN "CN=AD-Binder,OU=服务帐户,OU=用户和组,OU=<模糊>,DC=<模糊>,DC=<模糊>,DC=<模糊>,DC=<遮蔽>,DC=<遮蔽>"AuthLDAPBindPassword <模糊>要求 ldap-group CN=em_admin,OU=Groups,OU=Users and Groups,OU=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<遮蔽>,DC=<遮蔽></目录>

解决方案

问题出在我的登录表单上.根据关于Inline Login with Body Preservation"的 apache 文档;(

最后这里是我的 nagios.conf(我不包括相同的 nagios/share 目录):

仅供参考,在 login.php 的登录表单部分之外执行此操作,以确定此信息的保存位置:

I have both Nagvis and Nagios set up for LDAPS authentication. I have a monitor point (link) in Nagvis which brings me to the Service information in Nagios Core. When I click the link in Nagvis to get to Nagios I get the following error: /var/log/httpd24/error_log:

[cgi:error] [pid 25523] [client 155.157.39.194:23160] Premature end of script headers: status.cgi, referer: https://[EM Server FQDN]/nagios/cgi-bin/status.cgi?host=all

When I land at the next page I am met with an Internal Server Error page which just tells me to consult the error logs. Hitting F5 or the Back Navigation button on the browser resolves the issue. When I instead replace LDAPS authentication with Basic Authentication, no problems occur.

My CGI files have proper permissions. Something must be getting lost in the process of the LDAP authentication?

Any help is appreciated! Attached my nagios.conf...

   ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

   <Directory "/usr/local/nagios/sbin">
  SSLRequireSSL
  Options ExecCGI
  AllowOverride AuthConfig
  Order deny,allow
  Deny from all

  # Limit HTTP methods
  <LimitExcept GET POST OPTIONS>
       Require all denied
  </LimitExcept>

 Allow from <IP subnet of allowed hosts>
 Session on
 SessionCookieName httpd_nagsess path=/
 SessionMaxAge 1800
 SessionCryptoPassphrase <obscured>
 ErrorDocument 401 /auth/login.html

 AuthFormProvider ldap
 AuthType form
 AuthLDAPGroupAttributeIsDN on
 AuthName "Nagios Login via Active Directory (LDAPS)"
 AuthLDAPURL "ldaps://<domain controller #1 FQDN>:3269 <domain controller #2 FQDN>:3269/DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>?sAMAccountName?sub?(objectClass=*)" NONE
 AuthLDAPBindDN "CN=AD-Binder,OU=Service Accounts,OU=Users and Groups,OU=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>"
   AuthLDAPBindPassword <obscured>
   require ldap-group CN=em_admin,OU=Groups,OU=Users and Groups,OU=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>,DC=<obscured>

</Directory>

解决方案

The problem was with my login form. According to the apache documentation on "Inline Login with Body Preservation" (https://httpd.apache.org/docs/2.4/mod/mod_auth_form.html) I needed the following three lines in my form:

<input type="hidden" name="httpd_method" value="POST" />
<input type="hidden" name="httpd_mimetype" value="application/x-www-form-urlencoded" />
<input type="hidden" name="httpd_body" value="<?php echo $_SERVER['REDIRECT_QUERY_STRING'];?>" />

The PHP stuff given to the httpd_body was what I needed to actually preserve the original request. I found a few mentions out there of Inline Form Login not working out of the box but no solid solution for it. My solution works for me. Note login.html had to become login.php. See my login form below:

Finally here is my nagios.conf (Im not including identical nagios/share Directory):

FYI, did this outside the login form part of login.php to figure out where this info was held:

<?php
$info = phpinfo();
echo "<html><h2>$info</h2>";
?>

这篇关于脚本头过早结束:CGI、Nagios、LDAP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17