Nginx install and "The panel cannot connect to the API" problem

I use Laravel Forge and its default Nginx config works out-of-the-box with Kirby 3. I only had to add some rewrite rules to hide folders.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name yoursite.com;
    root /home/forge/yoursite.com;

    # SSL stuff goes here

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # Cachebuster
    # location ~ (.+)\.(?:\d+)\.(js|css)$ {
    #     try_files $uri $1.$2;
    # }

    # Media: images, icons, video, audio, HTC
    location ~ \.(jpe?g|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
      expires 1M;
      access_log off;
      add_header Cache-Control "public";
    }

    # Don't hint these as folders
    rewrite ^/(content|kirby|site|vendor)\/?$ /error last;

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

    # Block all files inside these folders from being accessed directly
    rewrite ^/(kirby|site|vendor)/(.*)$ /error last;

    # Block root /home/forge/yoursite.com;
    rewrite ^/(\.env|\.env\.example|composer\.json|composer\.lock|package.json|yarn.lock|mix-manifest\.json|webpack.mix.json|tailwind.js|readme\.md)$ /error last;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/yoursite.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

I hope that helps you figure out what’s going on on your side.