Forum Moderators: phranque

Message Too Old, No Replies

Header add dynamically

Header add dynamic server name

         

Xeonauz

9:09 pm on May 22, 2012 (gmt 0)

10+ Year Member



I manage several small clusters ranging from 8-12 machines each. I use the same httpd.conf on each machine within a cluster except for one minor difference. At the bottom of each httpd.conf I have the following:

Header add Cluster "MyServer03"

Where the name of the machine would be MyServer03. This is very handy in debugging in FireBug, knowing which server I'm hitting.

Unfortunately it makes it a pain when I want to change this file, because I have to do it individually on each box. I decided to write a script to change the last line for me and push it out, but then I thought that there must be a way in Apache to do something like this:

Header add Cluster "%SERVER_NAME"

Unfortunately that doesn't work, but it could be that I don't know the correct variable to use.

Any insight on this would be appreciated.

phranque

2:44 pm on May 23, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Xeonauz!

try this:
Header add Cluster %{SERVER_NAME}e

Xeonauz

5:45 pm on May 23, 2012 (gmt 0)

10+ Year Member



phranque, that worked perfectly! I really don't understand the e at the end... but it seems to be required.

Xeonauz

8:01 pm on May 23, 2012 (gmt 0)

10+ Year Member



Actually.... now that I've looked at it, all it's doing is echoing the name used to reach the server. For example, if I type in the IP address of the server, I get:

Cluster #*$!.#*$!.#*$!.#*$!

If I type in the machine name I get

Cluster machinename

When you don't specify a name in the httpd.conf, it uses the host to default to a name. I want that name to appear.

phranque

2:33 am on May 24, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the small 'e' is documented by apache:

http://httpd.apache.org/docs/2.0/mod/mod_headers.html#header:
%{FOOBAR}e The contents of the environment variable FOOBAR.


you can only access the environment variables that are available to the process in effect.

try this:
Header add Cluster %{HOSTNAME}e

or print out your environment variables from your script to see what else is available that may be useful.