# Conditional lua-load in the haproxy.cfg file

**URL:** <https://discourse.haproxy.org/t/conditional-lua-load-in-the-haproxy-cfg-file/6617>\
**Category:** Help!\
**Created:** [June 4, 2021, 2:28pm UTC](https://discourse.haproxy.org/t/conditional-lua-load-in-the-haproxy-cfg-file/6617 "2021-06-04T14:28:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mylinuxguy](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mylinuxguy](https://discourse.haproxy.org/u/mylinuxguy)\
**Post date:** [June 4, 2021, 2:28pm UTC](https://discourse.haproxy.org/t/conditional-lua-load-in-the-haproxy-cfg-file/6617/1 "2021-06-04T14:28:03Z")

</div>

I am trying to let haproxy access my letsencrypt ssl certs easier.

I am using haproxy 1.8 ( octopi setup )

I added a lua-load command to my global config section in my haproxy.cfg file. I used:  
lua-load \<path\_to\>/update\_haproxy\_ssl\_certs.lua  
and that lua script copies / merges the required ssl certs from my /etc/letsencrypt directory to the place / file that haproxy wants.

That all works great.

My question / issue is… can I have that lua-load command there and NOT fail if the file it wants to load does not exists. Can I have some sort of:

if file\_exists(\<path\_to\>/update\_haproxy\_ssl\_certs.lua) {  
lua-load \<path\_to\>/update\_haproxy\_ssl\_certs.lua  
}  
or  
lua-load-if-file-exists \<path\_to\>/update\_haproxy\_ssl\_certs.lua

The haproxy.cfg file is copied to multiple servers… but they don’t all have the letsencrypt ssl certs.

- thanks - jack

---

<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:** [June 5, 2021, 9:51am UTC](https://discourse.haproxy.org/t/conditional-lua-load-in-the-haproxy-cfg-file/6617/2 "2021-06-05T09:51:23Z")

</div>

No, this is not possible. You need to automate this yourself.
