简体   繁体   中英

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. 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:

$ 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:

ProxyPreserveHost

Just define it and set it to "on"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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