RanniSch / webserv

0 stars 2 forks source link

-PROBLEMS: Check CGI: The server is working fine using a CGI. #30

Closed RanniSch closed 1 year ago

RanniSch commented 1 year ago

Tested simple CGI with GET request and query variables. Tested with: http://localhost:8000/cgi-bin/script-get-2.py?a=b&c=d

Tested simple CGI with POST request. Tested with: http://localhost:8000/cgi-bin/script-post-2.py

solved max: for me it gives error 508 at MaxIhme can you try it again? For me it works fine. Maybe there was still the retun 508 in, to test the error code. Max: both adresses work fine via DockerLinux

MaxIhme commented 1 year ago

(index in location is set) http://localhost:8000/cgi-bin/ downloads the python script (on DockerLinux does not segfault anymore): on Docker Linux now is good

Config:

location /cgi-bin 
{
    allow_methods GET POST;
    index first_cgi.py;
    cgi_path /bin/bash /usr/bin/python3;
    cgi_ext .sh .py;
}

at MaxIhme this config does not work for me: Information: cannot open your config file. Will take default Config. ERROR in Config File: parameter 'cgi_path' should only have between 0 and 1 values

UPDATE from Max: Ahh right, to prevent errors I restricted cgi_path and cgi_ext to have only one variable. You have to do: Config:

location /cgi-bin 
{
    allow_methods GET POST;
    index first_cgi.py;
    cgi_path /usr/bin/python3;
    cgi_ext .py;
}
MaxIhme commented 1 year ago

http://localhost:8000/cgi-bin/

comes 403 Forbidden - correct behaviour

Config:

location /cgi-bin 
{
    allow_methods GET POST;
    cgi_path /bin/bash /usr/bin/python3;
    cgi_ext .sh .py;
}

at MaxIhme same problem like above: Information: cannot open your config file. Will take default Config. ERROR in Config File: parameter 'cgi_path' should only have between 0 and 1 values

Update: solution as above

MaxIhme commented 1 year ago

Config (wrong path to the python interpreter)

location /cgi-bin 
{
index first_cgi.py;
    allow_methods GET POST;
    cgi_path /bin/bash /usr/bin/pytho;
    cgi_ext .sh .py;
}

I get: "WRITING back to the socket: 9 fd: 9 error:0 WE HAVE FINISHED WRITING TO THE BROWSER Client Socket: 9 was closed successfuly File deleted successfully: tmp/tmp_file_9 Cgi destructor called! terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc make: *** [Makefile:85: e] Aborted"

->could you both test it (maybe I have a problem with my docker container) @RanniSch @LukasKava

http://localhost:8000/cgi-bin/ -> Bad alloc exception config: location /cgi-bin { allow_methods GET POST; index first_cgi.py; cgi_path /bin/bash;# /usr/bin/python3; cgi_ext .sh .py; }

@MaxIhme I used the actual default.conf file without changing anything. I opend with the browser: http://localhost:8000/cgi-bin/ it automatically goes to: http://localhost:8000/cgi-bin/script-get-2.py&w=d downloads the file and shows error code 404 in the browser.

MaxIhme commented 1 year ago

PROBLEM I also see that the script is downloaded... Bildschirmfoto 2023-11-02 um 12 50 51

Bildschirmfoto 2023-11-02 um 12 56 52

LukasKava commented 1 year ago

It seems like CGI works fine now.

RanniSch commented 1 year ago

Works fine now