Impossible to use plugins on LEMP stack

I’ve just installed a plugin, and I get the following error when loading the Panel. This is particularly odd as entering the url loads the page correctly. net::ERR_ABORTED 404

I am using a Nginx and PHP7.2, and having no issues with my local install using Valet.

The specific plugin installed is Retour by @distantnative, but as far as I know there is not a recommended Nginx setup for kirby… maybe this is the source of the issue? I have never encountered such an error before.

According to @bastianallgeier, these are the ones relevant for Kirby: Nginx issues - 500 error for media and panel 'No input file specified'

That does not seem to cut it. I have updated my Nginx config as per Bastian’s suggestion, but to no avail. What is strangest is that the response seems fine, but throws a 404 status code, as you can see by loading the following page:

I could not fully understand why this is the url that gets loaded, as there is no index.js file in /media/plugins/, and usually files in the media folder have a hash, such as:

There is a route that loads the index.js and index.css files from the plugins.

Indeed that’s what I’ve come to understand. Thankfully the Kirby core is well documented.

Any idea how I could inject some debugging code? Maybe fiddling with /kirby/config/routes.php? My nginx log only tells me that there is no such file, but really it should be loading index.php, right?

What if you explicitly add a code 200 in the route:

return $kirby

No, that does not work either. Here’s the full error log from Nginx if that helps. It seems the error is triggered even before it gets to the index.php bit.

Adding the following line to my Nginx config solves the issue, but then all the images break, so that’s not ideal:

rewrite ^/media/(.*)$ /index.php?$1;

I’m thinking maybe I should just go back to the old Apache…

EDIT: I’ve removed the full error log for security reasons, but look at the solution below for the relevant lines that helped solve the problem.

Let’s ask some people more familiar with this server stuff than me: @lukasbestle? @bastianallgeier?

Maybe dig around in Valet… thats Nginx based and kirby runs fine on that. Maybe if you dig into the Valet files and find the master Nginx config and the Kirby driver file, that will help you fix your own Nginx config.

I fixed it by removing expire rules, which would get triggered somehow.

# CSS and Javascript
location ~* \.(?:css|js)$ {
  add_header Cache-Control "max-age=31536000";
  access_log off;

I have removed the full error log for security reasons, but here are the relevant lines that tipped me off:

2020/02/05 18:55:29 [debug] 26801#26801: *3008 test location: ~ "\.php$"
2020/02/05 18:55:29 [debug] 26801#26801: *3008 test location: ~ "/\.ht"
2020/02/05 18:55:29 [debug] 26801#26801: *3008 test location: ~ "\.(?:css|js)$"
2020/02/05 18:55:29 [debug] 26801#26801: *3008 using configuration "\.(?:css|js)$" 
2020/02/05 18:55:29 [debug] 26801#26801: *3008 http filename: "/var/www/"
2020/02/05 18:55:29 [debug] 26801#26801: *3008 add cleanup: 0000999909999
2020/02/05 18:55:29 [error] 26801#26801: *3008 open() "/var/www/" failed (2: No such file or directory), client:, server:, request: "POST /media/plugins/index.js?1580850265 HTTP/1.1", host: ""
2020/02/05 18:55:29 [debug] 26801#26801: *3008 http finalize request: 404, "/media/plugins/index.js?1580850265" a:1, c:1
2020/02/05 18:55:29 [debug] 26801#26801: *3008 http special response: 404, "/media/plugins/index.js?1580850265"

Hope this can be of help to someone coming after me!

I’m glad you were able to fix it. We still need a better Nginx default config, but I’m not an Nginx expert to be quite honest and I don’t want to give wrong advice.


I think someone was able to keep expire rules while excluding the Panel from it, but don’t have the time now to search for it in the forum.

Yes, I’ll report here later, don’t worry about it now. Thanks for the help again @texnixe and @bastianallgeier !