Nginx proxying Caddy gives 404

1. The problem I’m having:

I have two different domains served with two different web servers:
sub.domain.com (Nginx)
domain.com (Caddy)
I have to create a reverse proxy from sub.domain.com/userinfo to domain.com/userinfo, so in Nginx I have set the proxy:

location /userinfo {
        proxy_pass https://domain.com;
        proxy_pass_request_body off; # no need to send the POST body

        proxy_set_header Content-Length "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # these return values are passed to the @error401 call
        auth_request_set $auth_resp_jwt $upstream_http_x_vouch_jwt;
        auth_request_set $auth_resp_err $upstream_http_x_vouch_err;
        auth_request_set $auth_resp_failcount $upstream_http_x_vouch_failcount;
    }

The issue is that when I visit sub.domain.com/userinfo, I get a 404 response, and Caddy logs nothing.

2. Error messages and/or full log output:

No logs (nothing is logged on Caddy)

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

3. Caddy version:

v2.10.0 h1:fonubSaQKF1YANl8TXqGcn4IbIRUDdfAkpcsfI/vX5U=

4. How I installed and ran Caddy:

Static binary, downloaded from caddy website

a. System environment:

OS: Ubuntu 22.04 (both)
Arch: x64 (both)

b. Command:

sudo ./caddy_linux_amd64 run

c. Service/unit/compose file:

d. My complete Caddy config:

{
	servers {
		trusted_proxies static 0.0.0.0/0
	}
	log
}

www.domain.com, domain.com, http://sub.domain.com {
    root * /var/www/vhosts/site/web/

    file_server {
        hide .htaccess
        index index.html index.htm index.php
    }

    php_fastcgi unix//run/php/php-fpm.sock

    log
}

5. Links to relevant resources:

{
    # To capture Caddy's log (such as configuration errors)...
    log default {
        output file /var/log/caddy/caddy.log
        format console
    }
    # other global options
}

# To capture the log of a particular domain in a log file (in json format)...
example.com {
    log {
        output file /var/log/caddy/access-example.com.json
    }
    # other directives
}

You might want to refer the following to understand how logging works in general…

If the generic logging doesn’t help, you might turn on debugging as mentioned in Global options (Caddyfile) — Caddy Documentation .