简体   繁体   English

剥离自定义HTTP标头字段

[英]Custom HTTP header fields stripped

My company sells a LAMP-based (where P = Perl, not PHP) application deployed as an appliance. 我的公司销售一个基于LAMP(其中P = Perl,而不是PHP)应用程序作为设备部署。 A customer is attempting to integrate their SiteMinder SSO with our application, such that our appliance sits behind a proxy running a SiteMinder Apache plugin that acts as a gatekeeper. 客户正在尝试将他们的SiteMinder SSO与我们的应用程序集成,以便我们的设备位于运行SiteMinder Apache插件的代理后面,该插件充当网守。 For our application to authenticate a user via SSO, we expect to see HTTP requests that include an SSO cookie (SMSESSION in this case) and a custom HTTP header variable containing the username. 对于我们的应用程序通过SSO对用户进行身份验证,我们希望看到包含SSO cookie(本例中为SMSESSION)的HTTP请求以及包含用户名的自定义HTTP头变量。

However, when our Apache server receives HTTP requests from the SSO proxy, all custom HTTP appear to have been stripped, although the cookie is present. 但是,当我们的Apache服务器从SSO代理接收HTTP请求时,尽管存在cookie,但所有自定义HTTP似乎都已被剥离。 I have instrumented the Perl code to write the headers to a log file with the following code: 我已经检测了Perl代码,使用以下代码将标头写入日志文件:

my $q = new CGI;
...
my %headers = map { $_ => $q->http($_) } $q->http();
my $headerDump = "Got the following headers:\n";
for my $header ( keys %headers ) {
    $headerDump = $headerDump . "$header: $headers{$header}\n";
}
kLogApacheError("info", $headerDump);

...and this is the output I get (slightly edited for confidentiality): ...这是我得到的输出(为保密而略微编辑):

[Wed Mar 16 23:47:31 UTC 2011] [info] Got the following headers:
        HTTP_COOKIE: s_vi=[CS]v1|26AE2FFD851D091F-4000012E400035C5[CE]; s_nr=1297899843493; [snip]
        HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
        HTTP_ACCEPT_ENCODING: gzip,deflate,sdch
        HTTP_CONNECTION: keep-alive
        HTTP_ACCEPT: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
        HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3
        HTTP_USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13
        HTTP_HOST: [redacted].com

IOW, the customer HTTP headers I'm expecting are missing. IOW,我期待的客户HTTP标头丢失了。 When we redirect traffic from the proxy to a different Apache server (ie not our appliance) all the 20+ custom headers show up as expected. 当我们将流量从代理重定向到不同的Apache服务器(即不是我们的设备)时,所有20多个自定义标头都会按预期显示。 This strongly suggests that it's our Apache server that is stripping the headers. 这强烈暗示我们的Apache服务器正在剥离标头。

We have never run into a problem like this with other deployments, even with this particular SSO solution. 即使使用这种特殊的SSO解决方案,我们也从未遇到过其他部署这样的问题。 I realize this is similar to another question on this site ( Server removes custom HTTP header fields ) but the suggestions there (such as a problem caused by running mod_security) don't apply. 我意识到这与此站点上的另一个问题类似( 服务器删除自定义HTTP标头字段 ),但那里的建议(例如运行mod_security导致的问题)不适用。

Is there any other reason why our server might be stripping out the HTTP headers? 我们的服务器可能正在剥离HTTP标头还有其他原因吗? Or is there possibly something else going on? 或者可能还有其他事情发生?

Thanks for any help! 谢谢你的帮助!

Matt 马特

Have you sniffed the raw HTTP traffic between the proxy and your Apache instance? 您是否嗅过代理与Apache实例之间的原始HTTP流量? If the necessary headers are missing herein, the problem is on the proxy side. 如果此处缺少必要的标头,则问题出在代理端。

I finally figured this out, and it was pretty obscure... 我终于弄清楚了,这很晦涩......

Using HttpFox, it really looked like traffic was being redirected to the appliance rather than being forwarded . 使用HttpFox,看起来流量被重定向到设备而不是被转发 In the case of redirects, cookies were persisting but HTTP request headers were not. 在重定向的情况下,cookie是持久的,但HTTP请求标头不是。 However, the SSO Proxy rules were all "forwards" so we were completely stumped as to why redirects were showing up. 但是,SSO代理规则都是“转发”,所以我们完全不知道为什么重定向会出现。

We knew that our application's logic redirects to /signin/ if the user isn't already authenticated but we expected this would still be routed through the proxy. 我们知道我们的应用程序的逻辑重定向到/ signin /如果用户尚未经过身份验证,但我们预计这仍将通过代理进行路由。 However, what we didn't realize is that there was a SiteMinder SSO option, enableredirectrewrite that by default would handle "any redirects initiated by destination servers [by passing them] back to the requesting user". 但是,我们没有意识到有一个SiteMinder SSO选项, enableredirectrewrite默认情况下会处理“目标服务器[通过传递它们]发回的任何重定向”回到请求用户“。 Once we set this flag to "yes", and the redirectrewritablehostnames to "all", everything worked like magic. 一旦我们将此标志设置为“yes”,并将redirectrewritablehostnames设置为“all”,一切都像魔术一样。

(For reference, see a version of the SiteMinder manual here: http://www.scribd.com/doc/48749285/h002921e ). (有关参考,请参阅SiteMinder手册的一个版本: http//www.scribd.com/doc/48749285/h002921e )。

I recently had a problem where I could not get any custom HTTP Headers passed to my PHP Script. 我最近遇到了一个问题,我无法将任何自定义HTTP标头传递给我的PHP脚本。 It seems that Apache 2 running PHP 7 with FCGID would not allowing and removing or tripping all custom HTTP Headers. 似乎运行带有FCGID的PHP 7的Apache 2不允许和删除或跳闸所有自定义HTTP标头。

Here is my fix: http://kiteplans.info/2017/06/13/solved-apache-2-php-7-fcgid-not-allowing-removing-stripping-custom-http-headers/ 这是我的修复: http//kiteplans.info/2017/06/13/solved-apache-2-php-7-fcgid-not-allowing-removing-stripping-custom-http-headers/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM