On 10 November 2011 17:40, Jan-Oliver John<[email protected]> wrote:
Hi guys,
is it possible to set a response header that includes the server id the
request has been sent to?
Maybe with "rspadd<something>"?
I'm not sure if rspadd is up to the job. I had a quick look and it
looks like the answer is 'no'.
I've got this working with Apache httpd backends though, if you're
using some other server as a backend feel free to ignore everything
that follows. :-)
Instructions are for apache2 on Ubuntu, so adjust as necessary.
Enable mod_headers:
$ sudo a2enmod headers
Add the following line to /etc/apache2/envvars:
export HOSTNAME=`hostname`
Add this somewhere in /etc/apache2/httpd.conf:
#Add server name header so we can identify backend server when
traffic passes through HAproxy
PassEnv HOSTNAME
Header set X-Backend-Server "%{HOSTNAME}e %D %t"
You can skip the %t and %D if you want, they just add the timestamp
Apache received the request and the duration of Apaches handling of
the request.
Thanks, Graeme.
This is what i formerly did in Nginx config ;-)
# export HOSTNAME=`hostname`
in nginx.conf:
env HOSTNAME;
http {
...
add_header X-Backend-Server $HOSTNAME;
...
}
I just wondered if it's possible to do this in haproxy and without
touching the backend's config....mhh, too bad!
Thanks,
Olli