Project

General

Profile

[UE] Server responds only if I am using root url pattern in mod_fastcgi

Added by Wido about 2 years ago

Hi, guys! Need help.

OS Lubuntu 21.10.
Client Firefox 97.0.2.
lighttpd -v
lighttpd/1.4.59 (ssl) - a light and fast webserver
lighttpd -tt -f /etc/lighttpd/lighttpd.conf
2022-03-09 20:41:58: configfile.c.2274) server.upload-dirs doesn't exist: /var/cache/lighttpd/uploads
I have tested only official Linux distro package.

I want to use only localhost/foo url to get access to the script.fcgi. But in configuration that included file present it is not working because of 404 and 403 on http://localhost/script.fcgi. If I replace "/foo" => with "/" => then I can get correct content via localhost url and localhost/script.fcgi (that is not that I need) provided by script.fcgi. I have installed in/out ALLOW tcp/lo on all ports rules in ufw. Please, help.

conf.txt (82.6 KB) conf.txt lighttpd -p -f /etc/lighttpd/lighttpd.conf

Replies (6)

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by gstrauss about 2 years ago

Please read the doc more carefully. Spelling matters, and misusing the directives likely has unintended results.
*.server options
mod_fastcgi options

Ignore other warnings at your own (further) peril.
2022-03-09 20:41:58: configfile.c.2274) server.upload-dirs doesn't exist: /var/cache/lighttpd/uploads

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by Wido about 2 years ago

Thanks.
Is this program correct?

#include <fcgi_stdio.h>
#include <stdlib.h>

int main (void) {

    while (FCGI_Accept() >= 0) {

        printf("Content-type: text/html\r\n\r\n" 
        "<!DOCTYPE html><html><body>" 
        "Hello!");

        printf("</body></html>\n");        
    }

    FCGI_SetExitStatus(200);
    FCGI_Finish();
    return EXIT_SUCCESS;
}

I have changed configuration to:

fastcgi.debug = 1
fastcgi.server = ( 
"/foo/" => ((
        "host" => "127.0.0.1",
        "port" => 80,            
            "bin-path" => "/var/www/html/script.fcgi",          
            "min-procs" => 1,
            "max-procs" => 1,
            "check-local" => "disable" 
        )))

Now, I get this in error.log and 500 error code on the http://localhost/foo/ in the Firefox:
2022-03-10 21:05:12: gw_backend.c.944) gw - found a host 127.0.0.1 80
2022-03-10 21:05:12: gw_backend.c.228) got proc: pid: 0 socket: tcp:127.0.0.1:80 load: 1
2022-03-10 21:05:12: connections.c.750) invalid request-line -> sending Status 400
2022-03-10 21:05:12: gw_backend.c.2340) error: unexpected close of gw connection for /foo/? (no gw process on socket: tcp:127.0.0.1:80 ?) 4
2022-03-10 21:05:12: gw_backend.c.303) released proc: pid: 0 socket: tcp:127.0.0.1:80 load: 0

What am I doing wrong?

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by gstrauss about 2 years ago

Is this program correct?

No, it does not look correct to me. I think the rest of your FCGI_* commands belong at the end of the while (FCGI_Accept() >= 0) loop.

2022-03-10 21:05:12: connections.c.750) invalid request-line -> sending Status 400

This suggests an additional error: lighttpd is rejecting a bad request from the client.

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by Wido about 2 years ago

I modified my code and configuration:

server.modules = ( "mod_rewrite", "mod_redirect", "mod_access", "mod_fastcgi", "mod_proxy", "mod_accesslog" )
server.document-root = "/var/www/html/" 
server.errorlog = "/var/log/lighttpd/error.log" 
server.upload-dirs = ("/tmp")
server.max-request-size = 40960
server.network-backend = "write" 
fastcgi.server = ( "" => ( ( "host" => "127.0.0.1",
                             "port" => 80, "min-procs" => 1,
                             "max-procs" => 1,
                             "check-local" => "disable",
                             "bin-path" => "/var/www/html/script.fcgi" ) ) )

Now I get 500 code in firefox on localhost and no errors in error.log. How to debug?

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by Wido about 2 years ago

Yes! This is my MVP configuration:

config {
    var.PID              = 8807
    var.CWD              = "/home/lovelake/Documents" 
    server.document-root = "/var/www/html" 
    server.modules       = ("mod_fastcgi")
    fastcgi.server       = (
        "/" => (
            (
                "bin-path"  => "/var/www/html/a.out",
                "host"      => "127.0.0.1",
                "port"      => 80,
                "max-procs" => 2,
                # 4
            ),
        ),
    )

}

But, how could I divide one route between multiple executables?

RE: [UE] Server responds only if I am using root url pattern in mod_fastcgi - Added by Wido about 2 years ago

I am trying to use fastcgi.server inside {} of conditional but it seems not working. Any ideas?

    (1-6/6)