[Solved] 403- Forbidden when try to load a cgi file
Added by rezsalehi about 6 years ago
Hello All,
I m trying to get lightthpd working on my embeded Linux device.
The installed version is :
/ # lighttpd -v
lighttpd/1.4.36 (ssl) - a light and fast webserver
Build-Date: Nov 9 2017 12:12:19
I can load all html file properly but when I try to load .cgi files I get 403 - Forbidden error on my browser and the following error in the log file:
pd/1.4.36-r0/lighttpd-1.4.36/src/mod_access.c.137) -- mod_access_uri_handler called
pd/1.4.36-r0/lighttpd-1.4.36/src/mod_staticfile.c.401) -- NOT handling file as static file, extension forbidden
pd/1.4.36-r0/lighttpd-1.4.36/src/server.c.1315) connection closed - keep-alive timeout: 7
I set the mod fo cgi file to 777.
I am using FireFox browser.
Attached you can find my lighttpd.conf.
I spent lot of time online but couldn't figure it out.
I appreciate your help.
Thanks,
Reza
lighttpd.conf (11.4 KB) lighttpd.conf |
Replies (6)
RE: 403- Forbidden when try to load a cgi file - Added by gstrauss about 6 years ago
Build-Date: Nov 9 2017 12:12:19
lighttpd 1.4.36 was released 19 July 2015
lighttpd 1.4.48 was released 11 Nov 2017, so you were almost 12 (!) releases behind when that was built.
Latest lighttpd release is lighttpd 1.4.53. In the 1,128 commits since lighttpd 1.4.36 there is a good chance that a bug fix or improvement was made, but if you want to try to get lighttpd 1.4.36 working, I recommend that you not make it internet-accessible as there have been a few security fixes since then.
If you expect to serve the file as CGI, then you'll have to configure cgi.assign
which is currently commented out.
NOT handling file as static file, extension forbidden
That behavior is intentional based on your config. static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" , ".cgi" )
prevents the .cgi from being served by mod_staticfile as plain text code.
RE: [Solved] 403- Forbidden when try to load a cgi file - Added by rezsalehi about 6 years ago
Thank you very much for the response.
I will try to update lighttd later but I need to get it to with work with existing version.
When I add the following lines: I won't get 403 any more but apparently gets seg fault and I see a blank page.
- CGI module
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
Do I need perl in order to run cgi?
Here is the log data:
r0/lighttpd-1.4.36/src/response.c.516) -- after doc_root
r0/lighttpd-1.4.36/src/response.c.517) Doc-Root : /data/www/pages/
r0/lighttpd-1.4.36/src/response.c.518) Rel-Path : /cgi-bin/reza.cgi
r0/lighttpd-1.4.36/src/response.c.519) Path : /data/www/pages/cgi-bin/re
r0/lighttpd-1.4.36/src/response.c.536) -- logical > physical handling physical path
r0/lighttpd-1.4.36/src/response.c.537) Doc-Root : /data/www/pages/
r0/lighttpd-1.4.36/src/response.c.538) Basedir : /data/www/pages/
r0/lighttpd-1.4.36/src/response.c.539) Rel-Path : /cgi-bin/reza.cgi
r0/lighttpd-1.4.36/src/response.c.540) Path : /data/www/pages/cgi-bin/re
r0/lighttpd-1.4.36/src/response.c.557) -
r0/lighttpd-1.4.36/src/response.c.558) Path : /data/www/pages/cgi-bin/re
r0/lighttpd-1.4.36/src/response.c.565) -- file found
r0/lighttpd-1.4.36/src/response.c.566) Path : /data/www/pages/cgi-bin/re
r0/lighttpd-1.4.36/src/response.c.716) -- handling subrequest
r0/lighttpd-1.4.36/src/response.c.717) Path : /data/www/pages/cgi-bin/re
r0/lighttpd-1.4.36/src/mod_access.c.137) -- mod_access_uri_handler called
r0/lighttpd-1.4.36/src/mod_cgi.c.1261) cleaning up CGI: process died with signal
r0/lighttpd-1.4.36/src/server.c.1315) connection closed - keep-alive timeout: 7
Here is the sample C file I try to load :
#include "stdio.h"
int main(void) {
printf( "Content-Type: text/plain\n\n" );
printf("Hello world !\n");
return 0;
}
Thanks,
Reza
RE: [Solved] 403- Forbidden when try to load a cgi file - Added by rezsalehi about 6 years ago
- CGI module
cgi.assign = ( ".pl" => "/usr/bin/perl" ,
".cgi" => "/usr/bin/" )
I would get the following ( signal 6) :
lighttpd-1.4.36/src/response.c.566) Path : /data/www/pages/cgi-bin/reza.
lighttpd-1.4.36/src/response.c.716) -- handling subrequest
lighttpd-1.4.36/src/response.c.717) Path : /data/www/pages/cgi-bin/reza.
lighttpd-1.4.36/src/mod_access.c.137) -- mod_access_uri_handler called
lighttpd-1.4.36/src/mod_cgi.c.1261) cleaning up CGI: process died with signal 6
lighttpd-1.4.36/src/server.c.1315) connection closed - keep-alive timeout: 7
RE: [Solved] 403- Forbidden when try to load a cgi file - Added by rezsalehi about 6 years ago
Just to mention that I can run reza.cgi as an executable in teh target with no issue.
In my two previous commit if cgi point to /usr/bin/perl I will see signal 11. 11 was left out from my commit above.
RE: [Solved] 403- Forbidden when try to load a cgi file - Added by gstrauss about 6 years ago
You created an account on this site to post in the Forums. Have you considered taking a peek at the documentation on this site?
See the "Wiki" tab at the top and look at documentation for mod_cgi.
RE: [Solved] 403- Forbidden when try to load a cgi file - Added by rezsalehi about 6 years ago
Thanks for the hint. I got my answer from cg_mod document.
I had to add the following:
cgi.assign = ( ".pl" => "/usr/bin/perl" ,
".cgi" => "" )