Hello,
we have a special requirement that we made it work with nginx but we are trying 
to accomplish the same with haproxy since nginx buffers uploads to disk and 
this behavior is not desiderable in this case.

We need to stream directly to the backend, however the backed ip address and 
port must be dictated by a client header (or other means).
I don't care about the security right now; in nginx I was able to construct the 
backend server address dinamically using header variables but here I'm a stuck.

I'm using haproxy stable.

However with the 'peer' concept in mind I tried to move steps in this direction:

backend nodejs_daemoner_http_specific_cluster
  balance hdr(X-Destination)
  hash-type consistent
  no option redispatch

  server  node_daemoner_http_5005 127.0.0.1:5005 id 5005 check
  server  node_daemoner_http_5006 127.0.0.1:5006 id 5006 check
  server  node_daemoner_http_5007 127.0.0.1:5007 id 5007 check

the problem is that even if we are sending the custom header with a hashed 
value md5(dst ip:port) it seems to fall back to round robin again for 
subsequential requests with the same hash. I'm not sure at this point if I got 
it totally wrong.
Plus this doesn't satisfy the requirement of being able to connect to specific 
backends: the very first connection should go directly to the backend specified 
by the client, without letting haproxy learning about the hash first.

As said the request can also be routed to other ip addresses outside the 
127.0.0.1, and it will be awesome to not have to define them all on every 
instance since haproxy is the frontend of our web stack on an ec2 image, which 
is then scaled horizontally under an elastic load balancer with hundreds of 
instances.

It's a particular requirement, but I wonder if it's possible at all.

To better understand this was the nginx conf:

  location @nodejsdaemonerspecific {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect   off;
    proxy_max_temp_file_size 0;
    proxy_buffering off;
    proxy_pass http://$http_x_destination_host:$http_x_destination_port;
  }

We are currently stuck at this point, any tip is appreciated.

Thanks.

Claudio

Reply via email to