# Set a variable in haproxy configuration and use it in Lua script

**URL:** <https://discourse.haproxy.org/t/set-a-variable-in-haproxy-configuration-and-use-it-in-lua-script/1164>\
**Category:** Help!\
**Created:** [April 10, 2017, 12:21pm UTC](https://discourse.haproxy.org/t/set-a-variable-in-haproxy-configuration-and-use-it-in-lua-script/1164 "2017-04-10T12:21:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasanna](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prasanna](https://discourse.haproxy.org/u/prasanna)\
**Post date:** [April 10, 2017, 12:21pm UTC](https://discourse.haproxy.org/t/set-a-variable-in-haproxy-configuration-and-use-it-in-lua-script/1164/1 "2017-04-10T12:21:23Z")

</div>

Hi,  
As we can give any name for the backends in haproxy configuration,I would like to know if there is any way to send a variable with a value (suppose a backend name),so that I’ll get this value in the lua script,and I would like to query for the status of servers in the lua script.Based on that I will set the health check response.

So,I would like to know how to set a variable in haproxy configuration and then use it in lua script.  
Thankyou.

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [September 26, 2018, 9:59am UTC](https://discourse.haproxy.org/t/set-a-variable-in-haproxy-configuration-and-use-it-in-lua-script/1164/2 "2018-09-26T09:59:31Z")

</div>

If you are just trying to create a local healtcheck response for downstream proxies, you should be able to achieve this with the [monitor fail](https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-monitor%20fail) option.

As for LUA, you should be able to pass variables in txn context or, at the very least, using a HTTP header.
