Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: Basic http server with cgi alongside Moode
#1
Hello,
I've recently installed Moode on raspberry 3b, and I would like to have a really basic http server on it aswell.

I start the server with:
python3 -m http.server --cgi 8001

I can access static html page without any issues. However, I have 3 dynamic pages, and I cant access them :


Code:
[color=#000000][font=Times New Roman]Error response[/font][/color]
[color=#000000][size=medium][font=Times New Roman]Error code: 403[/font][/size][/color]
[color=#000000][size=medium][font=Times New Roman]Message: CGI script is not executable ('/cgi-bin/index.py').[/font][/size][/color]
[color=#000000][size=medium][font=Times New Roman]Error code explanation: HTTPStatus.FORBIDDEN - Request forbidden -- authorization will not help.[/font][/size][/color]

To be sure its not a permission problem, i used chmod 777 on my files, and I run the python3 as root

I have also tried using port 8000, same results.

If I start the server with python3 -m http.server 8001, it correctly display the content of my file, but dont execute it.

I have the same setup on another raspbian (retropie) working without any issue.

Is there a global config or something that can prevent the execution of my files?

Thanks
Reply
#2
(07-19-2020, 08:40 PM)Mwoua Wrote: Hello,
I've recently installed Moode on raspberry 3b, and I would like to have a really basic http server on it aswell.

I start the server with:
python3 -m http.server --cgi 8001

I can access static html page without any issues. However, I have 3 dynamic pages, and I cant access them :


Code:
[color=#000000][font=Times New Roman]Error response[/font][/color]
[color=#000000][size=medium][font=Times New Roman]Error code: 403[/font][/size][/color]
[color=#000000][size=medium][font=Times New Roman]Message: CGI script is not executable ('/cgi-bin/index.py').[/font][/size][/color]
[color=#000000][size=medium][font=Times New Roman]Error code explanation: HTTPStatus.FORBIDDEN - Request forbidden -- authorization will not help.[/font][/size][/color]

To be sure its not a permission problem, i used chmod 777 on my files, and I run the python3 as root

I have also tried using port 8000, same results.

If I start the server with python3 -m http.server 8001, it correctly display the content of my file, but dont execute it.

I have the same setup on another raspbian (retropie) working without any issue.

Is there a global config or something that can prevent the execution of my files?

Thanks


I'm sure there's an appropriate forum for this but it has nothing to do with moOde.

Regards,
Kent
Reply
#3
I am asking here because because my other raspberry OS (retropie) use the same raspbian version and same python version and it works. So maybe a global config of MoodeOS is blocking cgi execution
Reply
#4
(07-20-2020, 01:35 PM)Mwoua Wrote: I am asking here because because my other raspberry OS (retropie) use the same raspbian version and same python version and it works. So maybe a global config of MoodeOS is blocking cgi execution

No.

Seriously, this is Web Server 101 stuff. It took me all of 5 minutes to look up the Python http module and http.server, copy and paste a trivial hello.py cgi script into a subdirectory of /home/pi on a moOde r6.7.0 player, invoke the server, and see ithe output of the script show up in a web browser. Ergo, not a moOde issue.

At this point I'm done with this thread. I'll leave with this quote from the documentation of http.server:

Quote:Note that CGI scripts will be run with UID of user nobody, for security reasons. Problems with the CGI script will be translated to error 403.


Regards,
Kent
Reply
#5
Well, your post helped me find the probable root cause.
The partition from where I try to run the webserver is mounted as

(rw,nosuid,nodev,noexec,noatime,nodiratime,uhelper=udisks)

It is automatically mounted by Moode (udisks-glue), so I updated /etc/udisks-glue.conf to not automount this partition, and everything works
Reply


Forum Jump: