Setting Host header with --header

1,412 views
Skip to first unread message

Jensen, Adam

unread,
Feb 25, 2011, 11:03:10 AM2/25/11
to siege...@googlegroups.com
Hello!

I'm attempting to test performance of a site we've got hosted by a farm of several servers behind a load balancer.  I would like to control which server node is running the test, but if I just specify the public URL of the site (e.g., http://www.example.com/path), that'll be up to the load balancer.  So, I need to be able to use the server node's host name in the URL, but then specify a different Host header for vhost selection.

On the command line, what I'm trying to do would look like this:

siege --get --header="Host: www.example.com" http://webfarm3/path

Unfortunately, it appears that Siege uses the hostname in the URL to send its own HTTP Host header prior to sending my custom one; the HTTP request looks like this:

GET /path HTTP/1.1
Host: webfarm3
Accept: */*
Accept-Encoding: gzip
User-Agent: JoeDog/1.00 [en] (X11; I; Siege 2.66)
Connection: close

Is there a way to stop Siege from sending that first "Host: webfarm3" header, so that Apache will respect the second custom "Host: www.example.com" header instead?

Thanks!
Adam Jensen
UNT Central Web Support

Remi Broemeling

unread,
Feb 25, 2011, 11:10:00 AM2/25/11
to siege...@googlegroups.com
Hi Adam,

What siege is doing is correct.  Normally the Host header is seeded directly from the URL.  If you want to set your own Host header without a contest from siege, you can do so by re-writing your URL to use the IP address of your load-balancer, i.e.

siege --get --header="Host: www.example.com" http://1.2.3.4/path

However, what it actually sounds like is that you want TWO Host headers -- one that the load-balancer can deal with, and then a second one that provides the vhost selection on the backend server.  To my knowledge this cannot be done.

If the webservers have external addresses, you should be able to bypass the load-balancer completely and just do this:

siege --get --header="Host: www.example.com" http://<IP-ADDRESS-OF-SERVER-HERE>/path

jazzslider

unread,
Feb 25, 2011, 11:33:19 AM2/25/11
to Siege Users
Nope, I'm not wanting to send two Host headers; that's actually the
problem.

To see what I'm getting at, compare siege's behavior here with
curl's. Consider the following:

Example 1 (without a custom Host header):
mybox:~# curl http://webfarm3/path -v
* About to connect() to webfarm3 port 80 (#0)
* Trying 1.2.3.4... connected
* Connected to webfarm3 (1.2.3.4) port 80 (#0)
> GET /path HTTP/1.1
> User-Agent: curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18
> Host: webfarm3
> Accept: */*
>
< HTTP/1.1 404 Not Found
[...]

In this instance, since I haven't specified the Host header explicitly
through the -H option, curl seeds it from the URL, just as Siege
does. However, if I do specify an explicit Host header, here's what
happens:

Example 2 (with a custom Host header):
mybox:~# curl http://webfarm3/path -v -H "Host: www.example.com"
* About to connect() to webfarm3 port 80 (#0)
* Trying 1.2.3.4... connected
* Connected to webfarm3 (1.2.3.4) port 80 (#0)
> GET /path HTTP/1.1
> User-Agent: curl/7.18.2 (i486-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18
> Accept: */*
> Host: www.example.com
>
< HTTP/1.1 200 OK
[...]

See what I mean? When you specify an explicit Host header through the
-H option, curl no longer seeds the Host header from the URL.
Instead, it uses the hostname in the URL to determine which host
should receive its HTTP request (webfarm3), and then provides a Host
header (www.example.com) that indicates which vhost the request is
for.

Siege's behavior is different. When you specify a Host header through
the --header option, siege still seeds the Host header from the URL,
in addition to sending your custom header. This results in a request
containing two Host headers, the second of which ends up getting
ignored by Apache (even though the second one is the Host header I
actually went to the trouble of sending explicitly). What I'd like is
to be able to stop siege from sending that first, URL-seeded Host
header in the event that I've specified a custom one through the --
header option.

Thanks!
Adam


On Feb 25, 10:10 am, Remi Broemeling <r...@broemeling.org> wrote:
> Hi Adam,
>
> What siege is doing is correct.  Normally the Host header is seeded directly
> from the URL.  If you want to set your own Host header without a contest
> from siege, you can do so by re-writing your URL to use the IP address of
> your load-balancer, i.e.
>
> siege --get --header="Host:www.example.com"http://1.2.3.4/path<http://webfarm3/path>
>
> However, what it actually sounds like is that you want TWO Host headers --
> one that the load-balancer can deal with, and then a second one that
> provides the vhost selection on the backend server.  To my knowledge this
> cannot be done.
>
> If the webservers have external addresses, you should be able to bypass the
> load-balancer completely and just do this:
>
> siege --get --header="Host:www.example.com"
> http://<IP-ADDRESS-OF-SERVER-HERE>/path <http://webfarm3/path>
>
>
>
>
>
>
>
> On Fri, Feb 25, 2011 at 09:03, Jensen, Adam <Adam.Jen...@unt.edu> wrote:
> > Hello!
>
> > I'm attempting to test performance of a site we've got hosted by a farm of
> > several servers behind a load balancer.  I would like to control which
> > server node is running the test, but if I just specify the public URL of the
> > site (e.g.,http://www.example.com/path), that'll be up to the load

Jason Yan

unread,
Mar 7, 2011, 7:54:26 PM3/7/11
to siege...@googlegroups.com, jazzslider
I ran into the same issue as Adam in the past. I wrote a patch [1] to
get around this issue which prevents a duplicate Host header from
being sent if one was provided from -H. This is also available from
my fork on github [2].

[1] https://github.com/tail/siege/commit/010778f39e8fb2abbb36001a22fee9446b17ddbb.diff
[2] https://github.com/tail/siege/

Jeff Fulmer

unread,
Mar 9, 2011, 9:22:48 AM3/9/11
to siege...@googlegroups.com
Jason,

I looked at the patch and it looks good. I'll include it in verbatim or in spirit for the next release.

Jeff

Jeff

unread,
Mar 10, 2011, 2:31:00 PM3/10/11
to Siege Users
Jason's header patch has been applied and released in the latest beta:

ftp://ftp.joedog.org/pub/siege/beta/siege-beta.tar.gz

Reply all
Reply to author
Forward
0 new messages