this post was submitted on 27 Jul 2024
1 points (100.0% liked)

nginx

4 readers
1 users here now

The nginx community on Reddit. Reddit gives you the best of the internet in one place.

founded 1 year ago
MODERATORS
 
The original post: /r/nginx by /u/5calV on 2024-07-26 22:14:58.

Hi, I hope someone here can help me, I don't know what to try anymore tbh.

I am trying to use cgi with fcgiwrap and nginx on a Debian Stable host.

Finding the correct setup for this was already a hustle! Now I got another problem:

I can access my index.html just fine over the browser, but when trying to access the shell script in the browser I get a 403.

I already tried to recursively 777 /var/www, just to test it out, without any luck. In my www directory the are two nested directories: "html" with an index.html, and "cgi-bin" with my shell script.

My nginx error log says this:

2024/07/26 23:55:49 [error] 3771#3771: *1 FastCGI sent in stderr: "Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?" while reading response header from upstream, client: 10.10.10.52, server: testserver, request: "GET /cgi-bin/hello.sh HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "IP"

This is my nginx config:

server {
    listen 80;
    server_name testserver;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location /cgi-bin/ {
        alias /var/www/cgi-bin/;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/cgi-bin$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT /var/www/html;
    }

I really hope someone can help me here. If you got ANY other idea on how to execute bash scripts on the host via HTML / Nginx, feel free to tell me about it! Also, should I switch to Apache / httpd? cgi seems to work much simpler with it?

Thank you for reading this far! :)

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here