Backend server host name as a custom header with Nginx
When using load balanced web servers it's often useful to know which server processed the request. There is a simple unobtrusive method to achieve this with the Nginx web server. Nginx conveniently populates the server's real host name to the $hostname variable, meaning that you can simply output this to a custom header in the global config file:
http {
...
# Show server host name as header
add_header X-Backend-Server $hostname;
}