Lua setting of uhttpd for Luci on OpenWrt 18.06

In the OpenWrt 18.06, Luci web interface has set lua prefix and handler as below setting

uhttpd.main.lua_prefix='/luci'
uhttpd.main.lua_handler='/usr/lib/lua/luci/sgi/uhttpd.lua'

But in OpenWrt v17.01 doesn't have the setting, so I can add my own lua script as below, and I can access Luci web interface and "/lua" URL in the same time.

uhttpd.main.lua_prefix='/lua'
uhttpd.main.lua_handler='/root/index.lua'

Once I add my own Lua scrpit replace the lua prefix and handler on OpenWrt 18.06, the original luci web page can't access anymore.
Can I add my Lua script and no effect on Luci web service when I use OpenWrt 18.06?

Support for multiple Lua prefixes added with https://git.openwrt.org/214146c6f298e593695c29b8c04a418dac914040

After installing version 2018-08-23, convert your config to:

config uhttpd
  ...
  list lua_prefix '/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
  list lua_prefix '/lua=/root/index.lua'
  ...

To make use of the feature.

Will cherry pick the uhttpd updates for the stable 18.06 branch after some testing exposure, so they'll be part of 18.06.2

I'm confused about the uci command setting. If I apply your solution then how to use uci command to set prefix?
Can I use below command to set Lua? Thanks a lot.

uci set uhttpd.main.lua_prefix='/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
uci set uhttpd.main.lua_prefix='/lua=/root/index.lua'

uci del uhttpd.main.lua_prefix
uci add_list uhttpd.main.lua_prefix='/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
uci add_list uhttpd.main.lua_prefix='/lua=/root/index.lua'

I base on 18.06.01 and update uhttp package to https://git.openwrt.org/56378bc1 and it uhttpd.git is https://git.openwrt.org/cdfc902 . I found below issue:

  1. Even remove lua_prefix, home page still redirect to luci page(cgi-bin/luci) and luci web still can work

uci del uhttpd.main.lua_prefix
uci commit uhttpd
/etc/init.d/uhttpd restart

  1. Only add lua_prefix='/lua=/root/index.lua', home page still redirect to luci page(cgi-bin/luci) and luci web still can work. And /lua page can access, no problem.

uci del uhttpd.main.lua_prefix
uci add_list uhttpd.main.lua_prefix='/lua=/root/index.lua'
uci commit uhttpd
/etc/init.d/uhttpd restart

In 18.06.01, if I change prefix to /lua, home page will redirect to /luci and web show " Not Found
The requested URL /luci was not found on this server."

uhttpd.main.lua_prefix='/lua'
uhttpd.main.lua_handler='/root/index.lua'

Could you help to check my issue? How to not redirect home page when I not set "uci add_list uhttpd.main.lua_prefix='/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'", thanks.

You need to remove /www/index.html and/or /www/cgi-bin/luci

There is issue when I install uhttpd-mod-lua package, uhttpd service not work.
I set lua_prefix as below command

uci del uhttpd.main.lua_prefix
uci add_list uhttpd.main.lua_prefix='/lua=/root/index.lua'
uci commit uhttpd
/etc/init.d/uhttpd restart

uhttpd web service not work when uhttpd-mod-lua package installed.

ps | grep uhttpd
13803 root      3492 S    grep uhttpd

But uhttpd service can work when uhttpd-mod-lua package removed

ps | grep uhttpd
10254 root      3492 S    grep uhttpd
26221 root      4140 S    /usr/sbin/uhttpd -f -h /www -r OpenWrt -x /cgi-bin -

I've test uhttpd 2018-11-28-cdfc902a-2 version and 2019-06-16-91fcac34-3, the issue both happened.
After check the issue happened when remove Luci package, it seems I can not use uhttpd server to run my Lua script without Luci.

update...
Sorry, I found that nixio lib be used in my Lua script, so that uhttpd service not work when I remove Luci. it's not a issue.