Moode Forum
[SOLVED] Basic http server with cgi alongside Moode - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: [SOLVED] Basic http server with cgi alongside Moode (/showthread.php?tid=2789)



Basic http server with cgi alongside Moode - Mwoua - 07-19-2020

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


RE: Basic http server with cgi alongside Moode - TheOldPresbyope - 07-19-2020

(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


RE: Basic http server with cgi alongside Moode - Mwoua - 07-20-2020

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


RE: Basic http server with cgi alongside Moode - TheOldPresbyope - 07-20-2020

(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


RE: Basic http server with cgi alongside Moode - Mwoua - 07-20-2020

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