简体   繁体   English

无法在负载均衡器后面的Amazon Linux上使用httpd设置HeaderRequest

[英]Not Able to Set HeaderRequest with httpd on Amazon Linux behind Load Balancer

We have a configuration where we front the server with EC2 Load Balancer. 我们有一个配置,使我们可以使用EC2负载均衡器在服务器前端。 Because of that, it seems that the "Host" is not properly set when it reaches the server. 因此,似乎“主机”在到达服务器时未正确设置。 Because of that we are trying to set the value using the proxy, but it doesn't seem to be working. 因此,我们正在尝试使用代理设置值,但是它似乎不起作用。 Below is the configuration: 下面是配置:

NameVirtualHost *:80

<VirtualHost *:80>
ServerAdmin admin@test.com
DocumentRoot "/mnt/dataebs/apache/test"
ServerName www.test.com
ServerAlias www.test.com
ErrorLog "/mnt/dataebs/apache/test-error.log"
CustomLog "/mnt/dataebs/apache/test-access.log" common

<Directory "/mnt/dataebs/apache/test">
    Options Indexes FollowSymLinks Includes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

RequestHeader set Host "www.test.com"
RequestHeader set Accept-Encoding "gzip, deflate"
ProxyPass /fabric http://<ip_address>/fabric
ProxyPassReverse /fabric http://<ip_address>/fabric

ProxyPassReverseCookiePath / /

</VirtualHost>

I have looked around for potential solution, but so far I haven't found one that actually solved the problem. 我一直在寻找潜在的解决方案,但是到目前为止,我还没有找到真正能够解决问题的解决方案。 I have also doubled checked to make sure mod_headers is enable: 我还仔细检查过以确保启用了mod_headers:

$ httpd -t -D DUMP_MODULES | grep header
Syntax OK
headers_module (shared)

Is there something else we need to include in the configuration? 我们还需要在配置中包含其他内容吗? How do you normally deal with this kind of case where the server is fronted by a load balancer? 通常情况下,服务器负载平衡器如何处理这种情况?

There is a specific directive in mod_proxy for that called: 在mod_proxy中有一个特定的指令称为:

ProxyPreserveHost

Just define it and set it to "on" 只需定义它并将其设置为“ on”

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

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