8

I have a cluster of Apache webservers using round-robin for primitive load balancing. Is there a way to have firefox or chrome request that server name from a specific IP?

If you just enter the http://1.2.3.4 , it doesn't get the ServerName, and if you enter http://servername, you could get any of the servers.

dmourati
  • 24,720
  • 2
  • 40
  • 69
Bryan Agee
  • 1,179
  • 2
  • 10
  • 27

2 Answers2

11

You need to modify the HTTP Host header.

See:

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

I do this with curl:

curl -H host:servername http://1.2.3.4

You may find the following plugins useful:

https://addons.mozilla.org/en-us/firefox/addon/modify-headers/

https://addons.mozilla.org/en-US/firefox/addon/tamper-data/eula/33806

dmourati
  • 24,720
  • 2
  • 40
  • 69
10

I assume you mean DNS round-robin. In that case the basic way I can think of is to just edit your /etc/hosts to point to whatever backend you want to try in a particular moment:

1.2.3.4 servername

You may have to restart your browser afterwards to make sure it isn't used a cached DNS answer.

Also you could add additional entries in your DNS like servername-001, -002, etc. and configure your backends to accept those names as a ServerAlias for the VirtualHost you're aiming for. Of course you could also just set the VirtualHost as default so it works using the IP and omit this last step, assuming your App doesn't assume it's running with a particular name.

Edit: This may be useful - it's a Firefox extension that lets you modify request headers. You could arguably modify Host to visit the backends directly specifying a ServerName. I haven't tried it though.

https://addons.mozilla.org/en-us/firefox/addon/modify-headers/

Eduardo Ivanec
  • 14,531
  • 1
  • 35
  • 42