Kirby 3 nginx config example

After banging my head against several 404s and 403s. I’ve got the starterkit and panel working.
Maybe someone finds this useful as a starting point (like future me in 2 months).

Disclaimer: I don’t really know what I’m doing and this config is used in a custom folder setup where only the media and the assets folder is exposed to public (I didn’t care to block requests to vendor / site / content / etc folders, because there were none).

upstream _php {
    server unix:/sock/docker.sock;
}

server {
    server_name localhost;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    index index.php;
    root /app/public;

    location /assets {
        try_files $uri =404;
        expires max;
        access_log off;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass _php;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Suggestions are welcome :slight_smile:

3 Likes