Lua setting of uhttpd for Luci on OpenWrt 18.06

#1

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?

Uhttpd not support PATCH http method?
#2

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

#3

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'

#4
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'
#5

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.

#6

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