OpenWrt Forum Archive

Topic: Bad gateway issue

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I have noticed an apparent problem with the uhttpd CGI interface. If I build an image that does not contain
LuCI then uHTTPd fails to start my CGI code. As a result I eventually receive a "bad gateway" message in my browser.
Nevertheless uHTTPd appears to serve static content correctly.

I should point out that that my CGI code is a stand alone binary, that has the appropriate permissions set
and resides in the /www/cgi-bin directory, that also has the appropriate permissions.

Installing luci at a later point, using:

    opkg install luci-mod-admin-full

(which in turn installs  the package luci-base) appears to fix the problem, so I have a valid work around.

Curiously if I then remove the installed packages with

    opkg remove luci-mod-admin-full
    opkg remove luci-base

my CGI code continues to work.

Perhaps it is relevant that  the directory /www/luci-static persists after removing these packages.

However deleting it using

    rm -r /www/luci-static

(or equivalents) also has no effect on the uHTTPd CGI.

In summary: it appears that the installation of all or parts of LuCI is necessary for the correct
functioning of uHTTPd's CGI mechanism.

Has anyone else noticed similar problems?

Rick

P.S. should mention Openwrt version is BB RC3 on TP-LINK WR1043ND V2

(Last edited by rcp100 on 8 Sep 2014, 18:04)

That souns really odd and is definitely not the case.
The root cause is likely something else in your cgi programs.

if you execute

opkg remove luci-mod-admin-full --autoremove

then did your script keep working? even after a reboot?

post opkg output anyway..

(Last edited by nebbia88 on 9 Sep 2014, 13:16)

@jow

> The root cause is likely something else in your cgi programs.

I agree (up to a point)

I suspect the problem may relate to my accessing:  /usr/lib/lua/luci/sys/zoneinfo/tzdata.lua

which certainly looks to me like it may be a LuCI file.

However, as far as I can tell at present, the code that accesses this file has not been called
at the point the error occurs.

I will investigate further when I get the chance.


@nebbia88

The command

    opkg remove luci-mod-admin-full --autoremove

yields only the message:

    Removing package luci-mod-admin-full from root ..

and my code continues to work correctly (specifically it continues to be able to read the
aforementioned tzdata.lua file) so it seems to me that this file does not 'belong to Luci'.

After a further reboot, my CGI code also continues to run correctly.

Thank you both for your input.

Perhaps I could ask at this point: is there a 'correct' way of accessing tzdata or zoneinfo
data under openWRT? Is it included as part of a package? Perhaps I should download my
own copy from the IANA repository?

Regards

Rick

The discussion might have continued from here.