Panel 404 — Nginx, Ubuntu and subdomain

Hi everyone,

I know this question pops up from time to time (believe me, I’ve googled and searched through tens of related questions) — but I can’t find any solution that works for me.

I have just installed Kirby 4 on a subdomain (i.e. sander.example.com). I run the server on Ubuntu 18 and Nginx with PHP8.2 (FPM). Every link works except the panel, which gives me a 404. I know there are tons of solutions out there and I implemented all of them one by one in my NGINX configuration, but nothing works.

The thing is, if I type out sander.example.com/panel/login it does show me the actual login screen — and if I type sander.example.com/panel/site I do get the main page of the panel, but all links give me this error: ‘The request to https://sander.example.com/panel/pages/projects failed’

I tried my kirby conf file for nginx from my other builds, but that doesn’t work. I have this about the panel in my conf file:

    rewrite ^/(content|site|kirby)/(.*)$ /error last;

    # Block content
    rewrite ^/content/(.*).(txt|md|mdown)$ /error last;

    # Block all files in the site and kirby folder from being accessed directly
    rewrite ^/(site|kirby)/(.*)$ /error last;

    # Panel links
    location /panel {
        autoindex off;
        try_files $uri $uri/ /panel/index.php?$query_string;
    }

I suspect it has something to do with Kirby running on a subdomain, but I’m not experienced enough with serversided development to find the issue. Does someone have a tip to push me in the right direction? Thank you!