[Nginx] Panel error

With my config, I have no stylesheets and no javascripts in the panel-backend.

server {
    listen 80;
    server_name codyteam.co www.codyteam.co;
    return 301 https://$server_name$request_uri;
}

    server {
      listen 443 spdy ssl;
    server_name codyteam.co www.codyteam.co;
    
    ssl on;
    ssl_certificate /etc/nginx/ssl/codyteam.co.crt;
    ssl_certificate_key /etc/nginx/ssl/codyteam.co.key;
    ssl_session_timeout  5m;
    ssl_session_cache    shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers   on;
    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
    ssl_stapling on;
    
    location / {
        root  /var/www/site;
        try_files  $uri  $uri/  /index.php?$args ;
        index  index.html index.htm index.php;
    }
    
    location ~ \.php$ {
        root  /var/www/site;
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        include fastcgi_params;
    }
    
    location /panel {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /panel/index.php last;
            break;
        }

        try_files $uri $uri/ /index.html;
    } 
    
    sendfile off;
}

Please take a look the Kirby NGINX example rules.

It also seems like your routing rules don’t apply to non-TLS access, maybe that’s the problem.

It don’t work.
Error:

The stylesheet https://codyteam.co/panel/assets/css/panel.css?v=2.1.2 was not loaded because its MIME type, "text/html", is not "text/css".

It looks like you didn’t include the mime.types configuration file (include /etc/nginx/mime.types).

Another reason could be that NGNIX does not serve the actual file but the Kirby error page. This depends on your routing setup.

I’ve used this config. https://gist.github.com/ramv/9402198

But, when I clicked Panel, file was automating download
https://codyteam.co/

This configuration uses /kirby as the URL root and /var/www/addons88/ as the file system web root and needs to be adapted, because your site is not installed in the subdirectory /kirby but /.

If that doesn’t work, please use the official example configuration I linked to above, third-party solutions aren’t officially supported.

I have the same issue. It seems indeed that the form.min.css & panel.min.css are redirected. I’m not able to directly open them through my browser.

[Error] Did not parse stylesheet at ‘http://pme.dev/panel/assets/css/form.min.css?v=2.2.3’ because non CSS MIME types are not allowed in strict mode.
[Error] Did not parse stylesheet at ‘http://pme.dev/panel/assets/css/panel.min.css?v=2.2.3’ because non CSS MIME types are not allowed in strict mode.

This are my configs:

user  martinrisseeuw staff;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    include       sites-enabled/*; # load virtuals config
    sendfile        on;
    keepalive_timeout  65;

    # gzip  on;
    # gzip_disable "MSIE [1-6]\.(?!.*SV1)";
}


server {
  listen                80;
  server_name           pme.dev;
  #access_log           /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code/pme.dev.access.log;
  #error_log            /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code/pme.dev.error.log;
  index index.php index.html index.htm;

  # Don't hint these as folders
  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;

  location / {
    root  /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code;
    try_files $uri $uri/ /index.php;
    index index.php;
  }

  location /panel {
    try_files $uri $uri/ /panel/index.php?$uri&$args;
  }

  location ~ \.php$ {
    root  /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code/;
    try_files  $uri  $uri/  /index.php?$args;
    index  index.html index.htm index.php;

    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include fastcgi_params;
  }
}

I have no idea how to setup the routing right? If that is the problem. Do you maybe have any suggestions what I could try?

Thanks

I know this is old, but I’m having the same issue and it doesn’t seem that a clear solutions has been published yet (please correct me if I’m wrong).

Let me clarify I’m using the official rules published in the gist that @lukasbestle linked in this thread.

Everything works as expected: except the panel assets.
Any thought on how I could debug this? @martinr, did you have any luck with this?

@puleddu Yea I fixed this issue, it was a problem from my side with my NGINX config, if I remember well. This is my updated file (sites-available). I forgot to set the root location of the server.

server {
  listen                80;
  server_name           pme.dev;
  #access_log           /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code/pme.dev.access.log;
  #error_log            /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code/pme.dev.error.log;
  root /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code;
  index index.php index.html index.htm;

  # Don't hint these as folders
  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;

  location / {
    root  /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code;
    try_files $uri $uri/ /index.php;
    index index.php;
  }

  location /panel {
    try_files $uri $uri/ /panel/index.php?$uri&$args;
  }

  location ~ /\.ht {
    deny all;
  }

  # Specify a charset
  charset utf-8;

  location ~ \.php$ {
    root  /Users/martinrisseeuw/Documents/Projects/platform_maker_educatie/code;
    try_files  $uri  $uri/  /index.php?$args;
    index  index.html index.htm index.php;

    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include fastcgi_params;
  }
}

Good luck!

Thank you @martinr . That was the issue of my configuration too.

If you define root in the main server block, there’s no need to define it on each location block.