Re: Setting a unique header per server in a backend
Thankyou Willy for the prompt response. We have a lot of servers, 100s of them, but we are generating the configs using scripts so this logically work for us, just that it would make the config long and complex. I will try it out. Thanks Sachin On Wed, Jan 2, 2019 at 7:43 PM Willy Tarreau wrote: > Hi Sachin, > > On Wed, Jan 02, 2019 at 07:33:03PM +0530, Sachin Shetty wrote: > > Hi Willy, > > > > It seems the http-send-name-header directive is not sent with > health-check > > and I need it in the health-check as well :) > > Indeed it's not supported there because the health checks are independant > on the traffic and could even be sent somewhere else. Also the request is > forged per backend and the same request is sent to all servers in the farm. > > > is there a way to make it work with health-check as well? > > There is a solution, it's not pretty, it depends on the number of servers > you're dealing with in your farm. The solution consists in replacing health > checks with trackers and to manually configure your health checks in > separate > backends, one per server. For example : > >backend my_prod_backend > server s1 1.1.1.1:80 track chk_s1/srv > server s2 1.1.1.2:80 track chk_s2/srv > server s3 1.1.1.3:80 track chk_s3/srv > >backend chk_s1 > option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s1" > server srv 1.1.1.1:80 check > >backend chk_s2 > option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s2" > server srv 1.1.1.1:80 check > >backend chk_s3 > option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s3" > server srv 1.1.1.1:80 check > > As you can see, the check is performed by these chk_* backends, and > reflected in the prod backend thanks to the "track" directive. I know > it's not pretty but it provides a lot of flexibility, including the > ability to have different checks per server. > > We definitely need to revamp all the check subsystem to bring more > flexibility... > > Cheers, > Willy >
Re: Setting a unique header per server in a backend
Hi Sachin, On Wed, Jan 02, 2019 at 07:33:03PM +0530, Sachin Shetty wrote: > Hi Willy, > > It seems the http-send-name-header directive is not sent with health-check > and I need it in the health-check as well :) Indeed it's not supported there because the health checks are independant on the traffic and could even be sent somewhere else. Also the request is forged per backend and the same request is sent to all servers in the farm. > is there a way to make it work with health-check as well? There is a solution, it's not pretty, it depends on the number of servers you're dealing with in your farm. The solution consists in replacing health checks with trackers and to manually configure your health checks in separate backends, one per server. For example : backend my_prod_backend server s1 1.1.1.1:80 track chk_s1/srv server s2 1.1.1.2:80 track chk_s2/srv server s3 1.1.1.3:80 track chk_s3/srv backend chk_s1 option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s1" server srv 1.1.1.1:80 check backend chk_s2 option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s2" server srv 1.1.1.1:80 check backend chk_s3 option httpchk GET /foo "HTTP/1.0\r\nHost: blah\r\nsrv: s3" server srv 1.1.1.1:80 check As you can see, the check is performed by these chk_* backends, and reflected in the prod backend thanks to the "track" directive. I know it's not pretty but it provides a lot of flexibility, including the ability to have different checks per server. We definitely need to revamp all the check subsystem to bring more flexibility... Cheers, Willy
Re: Setting a unique header per server in a backend
Hi Willy, It seems the http-send-name-header directive is not sent with health-check and I need it in the health-check as well :) is there a way to make it work with health-check as well? Thanks Sachin On Tue, Dec 18, 2018 at 5:18 PM Sachin Shetty wrote: > Thankyou Willy. http-send-name-header works for my use case. > > @Norman - Yes, we are looking at replacing the usage of X- headers. > > Thanks > Sachin > > On Mon, Dec 17, 2018 at 2:18 AM Norman Branitsky < > norman.branit...@micropact.com> wrote: > >> Don't forget the "X-" header prefix is deprecated: >> https://tools.ietf.org/html/rfc6648 >> >> Norman Branitsky >> >> On Dec 16, 2018, at 03:50, Willy Tarreau wrote: >> >> Hi Sachin, >> >> On Sat, Dec 15, 2018 at 10:32:21PM +0530, Sachin Shetty wrote: >> >> Hi, >> >> >> We have a tricky requirement to set a different header value in the >> request >> >> based on which server in a backend is picked. >> >> >> backend pod0 >> >>... >> >>server server1 server1:6180 check >> >>server server2 server2:6180 check >> >>server server3 server3:6180 check >> >> >> so when request is forwarded to server1 - I want to inject an header >> >> "X-Some-Header: Server1", "X-Some-Header: Server2" for server 2 and so >> >> on. >> >> >> You have this with "http-send-name-header", you need to pass it the >> header field name and it will fill the value with the server's name. >> It will even support redispatch by rewinding the stream and rewriting >> the value (which made it very tricky and infamous for quite some time). >> >> If it possible to register some lua action that would inject the header >> >> based on the server selected before the request is forwarded to the >> server. >> >> >> In fact except for the directive above it's not possible to perform >> changes after the server has been selected, because the server is >> selected when trying to connect, which happens after the contents are >> being forwarded, thus you can't perform any processing anymore. There >> is quite some ugly code to support http-send-name-header and it cannot >> be generalized at all. Just to give you an idea, think that a hash-based >> LB algo (balance uri, balance hdr) could decide to use some contents >> you're about to modify... So the contents have to be fixed before the >> server is chosen. >> >> Cheers, >> Willy >> >>
Re: Setting a unique header per server in a backend
Thankyou Willy. http-send-name-header works for my use case. @Norman - Yes, we are looking at replacing the usage of X- headers. Thanks Sachin On Mon, Dec 17, 2018 at 2:18 AM Norman Branitsky < norman.branit...@micropact.com> wrote: > Don't forget the "X-" header prefix is deprecated: > https://tools.ietf.org/html/rfc6648 > > Norman Branitsky > > On Dec 16, 2018, at 03:50, Willy Tarreau wrote: > > Hi Sachin, > > On Sat, Dec 15, 2018 at 10:32:21PM +0530, Sachin Shetty wrote: > > Hi, > > > We have a tricky requirement to set a different header value in the request > > based on which server in a backend is picked. > > > backend pod0 > >... > >server server1 server1:6180 check > >server server2 server2:6180 check > >server server3 server3:6180 check > > > so when request is forwarded to server1 - I want to inject an header > > "X-Some-Header: Server1", "X-Some-Header: Server2" for server 2 and so > > on. > > > You have this with "http-send-name-header", you need to pass it the > header field name and it will fill the value with the server's name. > It will even support redispatch by rewinding the stream and rewriting > the value (which made it very tricky and infamous for quite some time). > > If it possible to register some lua action that would inject the header > > based on the server selected before the request is forwarded to the > server. > > > In fact except for the directive above it's not possible to perform > changes after the server has been selected, because the server is > selected when trying to connect, which happens after the contents are > being forwarded, thus you can't perform any processing anymore. There > is quite some ugly code to support http-send-name-header and it cannot > be generalized at all. Just to give you an idea, think that a hash-based > LB algo (balance uri, balance hdr) could decide to use some contents > you're about to modify... So the contents have to be fixed before the > server is chosen. > > Cheers, > Willy > >
Re: Setting a unique header per server in a backend
Don't forget the "X-" header prefix is deprecated: https://tools.ietf.org/html/rfc6648 Norman Branitsky On Dec 16, 2018, at 03:50, Willy Tarreau mailto:w...@1wt.eu>> wrote: Hi Sachin, On Sat, Dec 15, 2018 at 10:32:21PM +0530, Sachin Shetty wrote: Hi, We have a tricky requirement to set a different header value in the request based on which server in a backend is picked. backend pod0 ... server server1 server1:6180 check server server2 server2:6180 check server server3 server3:6180 check so when request is forwarded to server1 - I want to inject an header "X-Some-Header: Server1", "X-Some-Header: Server2" for server 2 and so on. You have this with "http-send-name-header", you need to pass it the header field name and it will fill the value with the server's name. It will even support redispatch by rewinding the stream and rewriting the value (which made it very tricky and infamous for quite some time). If it possible to register some lua action that would inject the header based on the server selected before the request is forwarded to the server. In fact except for the directive above it's not possible to perform changes after the server has been selected, because the server is selected when trying to connect, which happens after the contents are being forwarded, thus you can't perform any processing anymore. There is quite some ugly code to support http-send-name-header and it cannot be generalized at all. Just to give you an idea, think that a hash-based LB algo (balance uri, balance hdr) could decide to use some contents you're about to modify... So the contents have to be fixed before the server is chosen. Cheers, Willy
Re: Setting a unique header per server in a backend
Hi Sachin, On Sat, Dec 15, 2018 at 10:32:21PM +0530, Sachin Shetty wrote: > Hi, > > We have a tricky requirement to set a different header value in the request > based on which server in a backend is picked. > > backend pod0 > ... > server server1 server1:6180 check > server server2 server2:6180 check > server server3 server3:6180 check > > so when request is forwarded to server1 - I want to inject an header > "X-Some-Header: Server1", "X-Some-Header: Server2" for server 2 and so > on. You have this with "http-send-name-header", you need to pass it the header field name and it will fill the value with the server's name. It will even support redispatch by rewinding the stream and rewriting the value (which made it very tricky and infamous for quite some time). > If it possible to register some lua action that would inject the header > based on the server selected before the request is forwarded to the server. In fact except for the directive above it's not possible to perform changes after the server has been selected, because the server is selected when trying to connect, which happens after the contents are being forwarded, thus you can't perform any processing anymore. There is quite some ugly code to support http-send-name-header and it cannot be generalized at all. Just to give you an idea, think that a hash-based LB algo (balance uri, balance hdr) could decide to use some contents you're about to modify... So the contents have to be fixed before the server is chosen. Cheers, Willy
Setting a unique header per server in a backend
Hi, We have a tricky requirement to set a different header value in the request based on which server in a backend is picked. backend pod0 ... server server1 server1:6180 check server server2 server2:6180 check server server3 server3:6180 check so when request is forwarded to server1 - I want to inject an header "X-Some-Header: Server1", "X-Some-Header: Server2" for server 2 and so on. If it possible to register some lua action that would inject the header based on the server selected before the request is forwarded to the server. Thanks Sachin