Nginx UDP load-balance hash from first 8 bytes

395 views Asked by At

I'm using nginx to load-balance logger UDP traffic in front of a set of graylog servers. Large log messages are broken apart into chunks then pieced back together using a message id of 8 bytes starting after a 2 byte header as explained in the GELF documentation: http://docs.graylog.org/en/2.3/pages/gelf.html

I would like to load balance messages based on these 8 bytes (or just the first ten bytes of the payload) however I'm not sure how to extract these bytes so that I can use them as a variable in the hash parameter:

upstream graylog_nodes {
    hash $first_ten_bytes;
    server 192.168.136.201:1812;
    server 192.168.136.202:1812;
}

Is this doable with nginx? Can custom variable by defined and used to route traffic?

http://nginx.org/en/docs/stream/ngx_stream_upstream_module.html

0

There are 0 answers