You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Frank X <mo...@paragenic.com> on 2013/10/04 03:00:49 UTC

[users@httpd] Proxy balancer and Apache Virtual Host rewrite single HTTP header

We have the following configuration, one apache HTTP server which proxies
AJP requests to an application on another host, as in the Proxy balancer
configuration below.

The problem we have is the application only understands one HOST http
header, i.e exampledomain.com, but we require www.exampledomain.com to be
rewritten to exampledomain.com however still show the
www.exampledomain.comaddress.

We also have HTTP proxies in between the browser and hitting the Apache
server, and do not want this content to be cached!

The following is our configuration:

<Proxy balancer://ajp-cluster>
Order deny,allow
Allow from all
BalancerMember ajp://10.10.10.11:8009
</Proxy>

<VirtualHost *:80>
ServerName exampledomain.com
ServerAlias exampledomain.com *.exampledomain.com
   RewriteEngine on
   RewriteCond %{HTTP_HOST} ^www.exampledomain.com
   RewriteRule ^/(.*)$ http://exampledomain.com/$1 [L,R=301,E=nocache:1]
   ## Set the response header if the "nocache" environment variable is set
   ## in the RewriteRule above.
   Header always set Cache-Control "no-store, no-cache,
must-revalidate" env=nocache
   ## Set Expires too ...
   Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT" env=nocache
   ProxyPass / balancer://ajp-cluster/
   ProxyPassReverse / balancer://ajp-cluster/
   </VirtualHost>

Re: [users@httpd] Proxy balancer and Apache Virtual Host rewrite single HTTP header

Posted by Igor Cicimov <ic...@gmail.com>.
On Fri, Oct 4, 2013 at 11:00 AM, Frank X <mo...@paragenic.com> wrote:

> We have the following configuration, one apache HTTP server which proxies
> AJP requests to an application on another host, as in the Proxy balancer
> configuration below.
>
> The problem we have is the application only understands one HOST http
> header, i.e exampledomain.com, but we require www.exampledomain.com to be
> rewritten to exampledomain.com however still show the
> www.exampledomain.com address.
>

Try adding ProxyPreserveHost. Also which header are you checking on the
backend side for the host name?

> We also have HTTP proxies in between the browser and hitting the Apache
> server, and do not want this content to be cached!
>
Ok, but I fail to understand the need of a variable here at all?

> The following is our configuration:
>
> <Proxy balancer://ajp-cluster>
> Order deny,allow
> Allow from all
> BalancerMember ajp://10.10.10.11:8009
> </Proxy>
>
> <VirtualHost *:80>
> ServerName exampledomain.com
> ServerAlias exampledomain.com *.exampledomain.com
>    RewriteEngine on
>    RewriteCond %{HTTP_HOST} ^www.exampledomain.com
>    RewriteRule ^/(.*)$ http://exampledomain.com/$1 [L,R=301,E=nocache:1]
>    ## Set the response header if the "nocache" environment variable is set
>    ## in the RewriteRule above.
>    Header always set Cache-Control "no-store, no-cache, must-revalidate" env=nocache
>    ## Set Expires too ...
>    Header always set Expires "Thu, 01 Jan 1970 00:00:00 GMT" env=nocache
>    ProxyPass / balancer://ajp-cluster/
>    ProxyPassReverse / balancer://ajp-cluster/
>    </VirtualHost>
>
>  Your balancer talks AJP to the backend server which is different from
HTTP. Also, I'm not sure you can use a variable set in the request phase in
your response rules.