[英]Forwarding Apache headers through proxy to Jetty
I have this in my Apache conf file: 我的Apache conf文件中有这个:
<IfModule headers_module>
SetEnv ntPrincipal "user@domain.com"
SetEnv legalGivenNames "Me"
SetEnv legalFamilyName "LastName"
SetEnv email "user@domain.com"
SetEnv partyId "123456"
SetEnv lang "eng"
#Set Env activeDirectoryGroup "Domain\GroupA"
</IfModule>
This enables the following in PHP $_SERVER['ntPrincipal']
. 这将在PHP $_SERVER['ntPrincipal']
启用以下功能。
The reason for this is to fake similar headers in our local development environments that are automatically injected (via Shibboleth) in our dev/test/prod environments. 原因是在我们的本地开发环境中伪造了类似的标头,这些标头在我们的开发/测试/生产环境中被自动注入(通过Shibboleth)。 This works fine for Apache/PHP. 这对于Apache / PHP很好。
The problem, my local environment now has to proxy to Jetty (unrelated independent app) and forward those same headers. 问题是,我的本地环境现在必须代理Jetty(无关的独立应用程序)并转发相同的标头。
Here is my Apache configuration: 这是我的Apache配置:
ProxyPass /daisy/ http://127.0.0.1:8888/
ProxyPassReverse /daisy/ http://127.0.0.1:8888/
ProxyHTMLURLMap http://127.0.0.1 /daisy/
<Location /daisy/>
ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap http://127.0.0.1:8888 /daisy/
ProxyHTMLURLMap / /daisy/
ProxyHTMLURLMap /daisy/ /daisy/
RequestHeader unset Accept-Encoding
</Location>
Update 1 更新1
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = headerNames.nextElement();
System.out.println(headerName);
Enumeration<String> headers = request.getHeaders(headerName);
while (headers.hasMoreElements()) {
String headerValue = headers.nextElement();
System.out.println(headerValue);
}
}
This piece of code lists all headers sent to Jetty. 这段代码列出了发送给Jetty的所有标头。 In this case, the headers available in PHP aren't available on Jetty. 在这种情况下,PHP中可用的标头在Jetty上不可用。
Here's what I ended up using that seems to work (both PHP and Jetty see the headers): 这是我最终使用的似乎有效的方法(PHP和Jetty均参见标头):
# PHP Headers
<IfModule headers_module>
SetEnv ntPrincipal "user@domain.com"
SetEnv legalGivenNames "user"
SetEnv legalFamilyName "lname"
SetEnv email "user.lname@domain.com"
SetEnv partyId "123456"
SetEnv lang "eng"
#Set Env activeDirectoryGroup "domain\group"
</IfModule>
# Daisy Headers
RequestHeader set ntPrincipal "user@domain.com"
RequestHeader set legalGivenNames "user"
RequestHeader set legalFamilyName "lname"
RequestHeader set email "user.lname@domain.com"
RequestHeader set partyId "123456"
RequestHeader set lang "eng"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.