Nginx auth_request module (Windows Problem)

So I have nginx running good and correctly. I used to have an nginx rewrite location block like so:

location ~ /auth-(.*) {
        rewrite ^/auth-(.*) /api/v2/auth?group=$1;
}

which I would use to auth_request against… i.e.

location /something {
            auth_request /auth-5;
            proxy_pass http://10.0.0.220:8988;
}

I would get Error 500 from nginx because Slim was returning:

2020/08/26 20:18:22 [error] 6396#17932: *3 FastCGI sent in stderr: "Slim Application Error:
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php
Line: 91
Trace: #0 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(57): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request))
#1 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner))
#2 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(89): class@anonymous->handle(Object(Slim\Psr7\Request))
#3 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous))
#4 C:\Projects\Organizr-V2\api\v2\index.php(114): class@anonymous->handle(Object(Slim\Psr7\Request))
#5 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\MiddlewareDispatcher.php(212): {closure}(Object(Slim\Psr7\Request), Object(class@anonymous))
#6 C:\Projects\Organizr-V2\api\v2\index.php(76): class@anonymous->handle(Object(Slim\Psr7\Request))
#7 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Lowercase->process(Object(Slim\Psr7\Request), Object(class@anonymous))
#8 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\MiddlewareDispatcher.php(64): class@anonymous->handle(Object(Slim\Psr7\Request))
#9 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\App.php(174): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request))
#10 C:\Projects\Organizr-V2\api\vendor\slim\slim\Slim\App.php(158): Slim\App->handle(Object(Slim\Psr7\Request))
#11 C:\Projects\Organizr-V2\api\v2\index.php(147): Slim\App->run()
#12 {main}

The issue is when I goto /api/v2/auth?group=5 I get the correct response, if I goto /auth-5 I would get that same error above.

Okay, so I thought I could get around this… So I made a new endpoint… /auth-{group} with Slim… I verified that it worked by going to /api/v2/auth-5 and getting the correct response.

The only issue now, is if I used that in the location block i.e.

location /something {
            auth_request /api/v2/auth-5;
            proxy_pass http://10.0.0.220:8988;
}

I get an Nginx error 500 and in the nginx logs, I see the exact same 404 error from slim… I am at a total loss… I can’t figure out what the heck is happening…

It works fine if I auth a subdomain using auth_request from a location block that is reverse proxied though…

does the auth_request mess with slim somehow?? I don’t think it does as I have the exact same setup using docker containers and nginx works as usual…

Any help???

EDIT:
I’m guessing it has to do with the setBasePath as I think nginx is calling the script a different way and it is messing with the path…

Also here are my endpoints:

$app->get('/auth', function ($request, $response, $args) {
	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
	$Organizr->auth();
	$response->getBody()->write(jsonE($GLOBALS['api']));
	return $response
		->withHeader('Content-Type', 'application/json;charset=UTF-8')
		->withStatus($GLOBALS['responseCode']);
});

$app->get('/auth-{group}', function ($request, $response, $args) {
	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
	$_GET['group'] = $args['group'];
	$Organizr->auth();
	$response->getBody()->write(jsonE($GLOBALS['api']));
	return $response
		->withHeader('Content-Type', 'application/json;charset=UTF-8')
		->withStatus($GLOBALS['responseCode']);
});

The webserver should only point to the front controller resp. the public/ directory.
Then Slim can handle the routing correctly.

Have you tried this setup for nginx?

https://www.slimframework.com/docs/v4/start/web-servers.html#nginx-configuration

Yes, I ended up finding that the issue is the way nginx forwards the auth_request… I had to circumvent using setBasePath to check request_uri and set accordingly.