Linux 4 All

Best Linux tricks source

X-Served-By Header

  • In Linux
  • On 22 Nov | '2014

Apache has the ability to return its Hostname via the X-Served-By header. When troubleshooting nodes behind a Load Balancer, this can help localize a problematic node.

Configuration:
Export the server’s hostname to Apache:

CentOS File: /etc/sysconfig/httpd
Ubuntu File: /etc/apache2/envvars

Add the following to Apache’s environment configuration file:

export HOSTNAME=$(hostname)

Add the X-Served-By header

Add the following to a Virtual Host or any other Apache configuration file:


PassEnv HOSTNAME
Header set X-Served-By "%{HOSTNAME}e"


The above lines require that mod_headers is enabled. Make sure that this module is enabled if you encounter any issues

Restart Apache:

service httpd restart
service apache2 restart

Get MySQL InnoDB tables arrow-right
Next post

arrow-left Top 10 memory Apache processes
Previous post

Leave a Reply

Your email address will not be published. Required fields are marked *