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

634 views Asked by At

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 [email protected]
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?

1

There are 1 answers

0
Daniel Ferradal On

There is a specific directive in mod_proxy for that called:

ProxyPreserveHost

Just define it and set it to "on"