Cgi-bin script not working on lighttpd

Hi guys,

I’m trying to enable NUTS (Network UPS Tools) in my Turris. Everything went well, appropriate usb driver were loaded and I also configured NUT server. After installing ups client (nut-upsc) I was able to view ups status by typing upsc server@localhost.
The thing is, I tried to end my configuration by installing nut-web-cgi package. It did what what intended, by installing multiple cgi scripts at /www/cgi-bin/nut directory. However, even though getting a proper html output when manually running upstarts.cgi script (with or without root privileges) I’m still getting http 500 internal server error when typing https://192.168.1.1/cgi-bin/nut/upsstats.cgi in my web browser.
Here is my /var/log/lighttpd/error.log file content:

2022-07-28 02:03:50: (…/src/server.c.1551) server started (lighttpd/1.4.63)
2022-07-29 06:27:17: (…/src/mod_cgi.c.753) stat for cgi-handler /usr/bin/perl: No such file or directory

A side note: I tried earlier to fix this error by installing perl package, and I still got the same http 500 internal server error.
Any ideas how to fix it?

Do you have the perl?

I already tried to install perl but the error persisted. The only difference after installing perl is that the http 500 error takes a while to appear and no error is recorded in the file /var/log/lighttpd/error.log

And which packages you installed?

I installed the following packages:

nut - 2.7.4-22
nut-common - 2.7.4-22
nut-driver-usbhid-ups - 2.7.4-22
nut-server - 2.7.4-22
nut-upsc - 2.7.4-22
nut-web-cgi - 2.7.4-22

And which perl packages you installed?

I presume the latest:

perl - 5.28.1-4

And which other per packages you installed? What the current logs?

Dear Viktor,

I didn’t get your point. I’ve already made a throroughtly analisis of current system log and no error was found, neither from NUTS nor any other service. The only error recorded was in lighttpd log file (as mentioned earlier), that ceases after installing perl.
I found that there isn’t a nut config file in /etc/lighttpd/conf.d. What do you think?
Here is my /etc/lighttpd/conf.ddirectory contents:

325 drwxr-xr-x 1 root root 208 Jul 9 09:11 .
322 drwxr-xr-x 1 root root 84 May 26 16:59 …
331 -rw-r–r-- 1 root root 150 May 4 02:39 foris-ws.conf
329 -rw-r–r-- 1 root root 881 May 4 02:39 luci.conf
70538 -rw-r–r-- 1 root root 507 May 27 12:43 nextcloud.conf
330 -rw-r–r-- 1 root root 169 May 4 02:39 reforis.conf
326 -rw------- 1 root root 124 May 4 02:39 srv.conf
40306 -rw-r–r-- 1 root root 2.5K May 26 17:03 ssl-enable.conf
46171 -rw-r–r-- 1 root root 628 May 4 02:39 transmission.conf
327 -rw-r–r-- 1 root root 431 May 4 02:39 turris-root.conf

Probably you have typo in the url what you put to the browser.

Be sure that the file upsstats.cgi exists or correct the url if there is typo.

1 Like

I am running into the same issue…

The problem is that we have

cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                               ".cgi" => "/usr/bin/perl",
                               ".rb"  => "/usr/bin/ruby",
                               ".erb" => "/usr/bin/eruby",                                                                              
                               ".py"  => "/usr/bin/python" )     

in /etc/lighttpd/modules.d/30-cgi.load which associates .cgi files with perl, while the nut CGI’s are plain executable…

Removing the association solves the nut issue, but it might have some side effects (I don’t think so as I don’t have perl installed anyway…)

To remove the association:

cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                               ".cgi" => "",
                               ".rb"  => "/usr/bin/ruby",
                               ".erb" => "/usr/bin/eruby",                                                                              
                               ".py"  => "/usr/bin/python" )

There might be a cleaner way, but the above works for me :wink:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.