adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 127 forks source link

scgi error with nginx #288

Closed o3o closed 3 years ago

o3o commented 3 years ago

I have a server with this simple program

import arsd.cgi;

void hello(Cgi cgi) {
    cgi.setResponseContentType("text/plain");
    if("name" in cgi.get)
        cgi.write("Hello, " ~ cgi.get["name"]);
    else
        cgi.write("Hello, world!");
}

mixin GenericMain!hello;

My dub.sdl

name "arsd_cgi"
description "cgi test"

dependency "arsd-official:cgi" version="~>8.2.0"

subConfiguration "arsd-official:cgi" "scgi"

I use nginx, my nginx.conf

http {

server {
        listen 80;

        location / {
                include   scgi_params;
                scgi_pass localhost:8080;
        }
}

So, I start app in server 192.168.221.113

./arsd_cgi --port 8080

when I open http://192.168.221.113/ in my browser:

arsd.cgi.ConnectionClosedException@../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d(4545): can't get any more data from a closed source<br />
----------------<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:527 void arsd.cgi.BufferedInputRange.popFront(ulong, ulong, bool) [0x561ddfe09527]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:1722 arsd.cgi.Cgi arsd.cgi.Cgi.__ctor(arsd.cgi.BufferedInputRange, immutable(char)[], ushort, int, bool, void delegate(const(ubyte)[]), void delegate(), bool*) [0x561ddfe03ebc]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:1641 arsd.cgi.Cgi arsd.cgi.Cgi.__ctor(arsd.cgi.BufferedInputRange, bool*) [0x561ddfe03c81]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:3662 void arsd.cgi.serveEmbeddedHttpdProcesses!(app.hello(arsd.cgi.Cgi), arsd.cgi.Cgi).serveEmbeddedHttpdProcesses(arsd.cgi.RequestServer) [0x561ddfdfc243]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:3500 void arsd.cgi.RequestServer.serve!(app.hello(arsd.cgi.Cgi), arsd.cgi.Cgi, 5000000L).serve() [0x561ddfdfbe14]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:3946 void arsd.cgi.cgiMainImpl!(app.hello(arsd.cgi.Cgi), arsd.cgi.Cgi, 5000000L).cgiMainImpl(immutable(char)[][]) [0x561ddfdfbcf6]<br />
../../.dub/packages/arsd-official-9.3.1/arsd-official/cgi.d:3320 _Dmain [0x561ddfde7abb]

Thank you

adamdruppe commented 3 years ago

That's serving embedded httpd, not scgi...

must have to do with the dub subconfiguration or something

adamdruppe commented 3 years ago

the config aslo says ~>8.2.0 but the stack trace shows 9.3.1. are you sure you're running the same build?

o3o commented 3 years ago

I'm sorry, I've copied wrong file This is the right one

name "arsd_cgi_test"
description "Arsd CGI examples"
authors "o3o"
copyright "Copyright © 2021, o3o"

dependency "arsd-official:cgi" version="~>9.3.1"
dependency "tinyredis" version="~>2.2.1"
dependency "tinyredis_util" version="~>0.4.0"

versions "embedded_httpd"

/*
- embedded_httpd for the embedded httpd version (built-in web server). This is the default.
- cgi for traditional cgi binaries.
- fastcgi for FastCGI builds.
- scgi for SCGI builds
*/
subConfiguration "arsd-official:cgi" "scgi"
adamdruppe commented 3 years ago

why is this there?

versions "embedded_httpd"

o3o commented 3 years ago

because I'm an idiot ...removed and now works! I'm sorry for the inconvenience

Thank you

adamdruppe commented 3 years ago

oh it happens

nowadays i actually compile in all the options so instead of the versions i might suggest new code call the functions directly. but im not quite ready to document that yet lol