[Solved] CGI bash script - 403 Forbidden error
Added by greenc over 10 years ago
Unable to get a bash script to work with CGI.
This is Ubuntu at Wiki Labs. The system default conf is here:
https://wikitech.wikimedia.org/wiki/Nova_Resource:Tools/Help#Default_configuration
Changes to the default are made in a .lighttp.conf in the home directory. It contains:
static-file.exclude-extensions += ( ".sh" ) alias.url += ( "/cgi-bin" => "$home/public_html/cgi-bin/" ) $HTTP["url"] == "/cgi-bin" { cgi.assign = ( ".sh" => "" ) }
The document root directory looks like this:
tools@tools-login:~/public_html$ ls -l drwxrwsr-x 2 tools tools 4096 Sep 19 15:40 cgi-bin
cgi-bin directory contain this:
tools@tools-login:~/public_html/cgi-bin$ ls -l -rwxr-xr-x 1 tools tools 67 Sep 19 15:31 test.sh
test.sh is this:
#!/bin/sh echo "Content-type: text/html<br><br>" echo "I am here."
I've tried so many things in the .lighttpd.conf and nothing seems to work. Sometimes I can get it display the output ("I am here") but it's not in HTML format (ie. not being interpreted as a CGI script). I don't have access to sudo or the server logs, only the error and access logs and they don't say much.
Any ideas?
Replies (3)
RE: [Solved] CGI bash script - 403 Forbidden error - Added by gstrauss about 8 years ago
Replace $home
with /home/tools
or whatever is appropriate. lighttpd does not perform per-request variable substitution in that part of the config.
Your shell script is an invalid CGI/1.1 response. Try this:
#!/bin/sh echo "Content-type: text/html" echo echo "<html><head></head><body>I am here.</body></html>"
RE: [Solved] CGI bash script - 403 Forbidden error - Added by migajohn about 7 years ago
Hello,
I have same problem, I can't execute cgi from internet network , somebody have an idea?
/etc/lighttpd/lighttpd.conf
server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", "mod_rewrite", "mod_cgi", ) server.document-root = "/var/www/html" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) # default listening port for IPv6 falls back to the IPv4 port ## Use ipv6 if available #include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" cgi.assign = ( ".sh" => "/bin/sh" ) static-file.exclude-extensions += ( ".sh" ) alias.url += ( "/cgi-bin" => "/var/www/cgi-bin/" ) $HTTP["url"] == "/cgi-bin" { cgi.assign = ( ".sh" => "" ) }
mjpg-streamer
sudo /opt/mjpg-streamer/mjpg_streamer -i "/opt/mjpg-streamer/input_uvc.so -d /dev/video0" -o "/opt/mjpg-streamer/output_http.so -p 81 -w /var/www"
Thanks
Capture d’écran de 2018-04-21 18-47-28.png (384 KB) Capture d’écran de 2018-04-21 18-47-28.png | outside network | ||
Capture d’écran de 2018-04-21 18-48-07.png (348 KB) Capture d’écran de 2018-04-21 18-48-07.png | home network |
RE: [Solved] CGI bash script - 403 Forbidden error - Added by gstrauss about 7 years ago
@migajohn: it is inappropriate to post an unrelated issue to a ticket that is a year old and solved. Your issue is unrelated. If it works "inside" but not "outside", then the links you are generating will not work "outside". See Docs_ModProxy