Auteur Sujet: Admin assets not loading (404)  (Lu 2292 fois)

tszym

  • Newbie
  • *
  • Messages: 2
    • Voir le profil
Admin assets not loading (404)
« le: 27 août 2015, 18:00:54 »
Mushraider v1.6.1

PHP 5.4.16 with php-fpm, Ngnix 1.8.0, mysql  Ver 15.1 Distrib 5.5.44-MariaDB

On a fresh install, evrything works find for the installation.
Then on /admin/ pages, some assets are not loadable (404).

Firefox console shows issues on:
https://domain.com/admin/js/jquery.dataTables.min.js
https://domain.com/admin/js/spectrum.min.js
https://domain.com/admin/js/script.js?v=1.6.1

And the same for the css files on /admin/css/

I foud these files in app/Plugin/Admin/webroot/js/ (and css/), but I don't know how this is supposed to be found by nginx. All read/write permissions are ok on these files & folders.

I tried to use the NginX config I was using with v1.5.2.2 that does not specify special things about these admin assets.

The nginx config:

server {
  listen 443 ssl;
  server_name domain.com;

  # some SSL stuff

  root /srv/http/mushraider/app/webroot;

  index index.php index.html index.htm;

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

location ~ \.php(?:$|/) {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param HTTPS on;
  fastcgi_pass php-handler;
}
}

NginX logs just shows 404s on the /admin/(js|css)/* path.

This is an issue not having these files, because I think this is the reason I cannot import games.

I tried to activate debug mode and load /admin/settings, but there is no app/tmp/logs/error.log generated.

Also on the page, I have many SQL requests in the footer, ith numbers >0 in the    Error   Affected column, don't know if you need them.

Thanks for your help!

Mush

  • Mushraider
  • Administrator
  • Hero Member
  • *****
  • Messages: 768
  • Meh.
    • Voir le profil
    • MushRaider
Re : Admin assets not loading (404)
« Réponse #1 le: 31 août 2015, 16:50:39 »
First things first, you have to convert the .htaccess files (at least the one in /app/webroot) to your nginx config (using a tool like http://winginx.com/en/htaccess)

You also need the write permissions for
/tmp
/app/Config
/app/webroot/Files

The sql queries in the footer are displayed when you have debug level > 0
MushRaider - modern raid planner for modern raiders
Me suivre sur  twitter and Google+
Soutenir le projet et me payer une bière =)

tszym

  • Newbie
  • *
  • Messages: 2
    • Voir le profil
Re : Admin assets not loading (404)
« Réponse #2 le: 07 sept. 2015, 18:53:24 »
Thanks for your help.

Write permissions are all fine.

I tried to change the nginx config with the tool you pointed, but this fails to serve any page.
Si I tried to just get the idea in /app/webroot/.htaccess

If this is not a file, nor a directory, use index.php and append the args.
For this, I use the Nginx try_files directive:
try_files $uri $uri/ /index.php?$args;

This with the root directive at /srv/http/mushraider/app/webroot;

This basically serve files or directories when found, or use index.php with args.
This was already the initial configuration I tried.

So for /admin/js/jquery.dataTables.min.js I think Nginx see there is no /app/webroot/admin directory, and try index.php
But we still have 404.

The error log shows things like this:
2015/09/07 18:40:22 [error] 12925#0: *815 open() "/srv/http/mushraider/app/webroot/admin/js/scripts.js" failed (2: No such file or directory)

Thanks for reading.

Mush

  • Mushraider
  • Administrator
  • Hero Member
  • *****
  • Messages: 768
  • Meh.
    • Voir le profil
    • MushRaider
Re : Admin assets not loading (404)
« Réponse #3 le: 08 sept. 2015, 11:32:13 »
I guess you have to add something like this in your nginx config

location / {
    if (!-e $request_filename){
         rewrite ^(.*)$ /index.php break;
    }
}

As I don't officially support nginx, here is the official documentation of the framework MushRaider is based on : http://book.cakephp.org/2.0/en/installation/url-rewriting.html#pretty-urls-on-nginx

I know that there are some communities using MushRaider with nginx without problem, but I don't have any nginx server anymore so I can't help more :x
MushRaider - modern raid planner for modern raiders
Me suivre sur  twitter and Google+
Soutenir le projet et me payer une bière =)

Andreas Klein

  • Newbie
  • *
  • Messages: 10
    • Voir le profil
Re : Admin assets not loading (404)
« Réponse #4 le: 23 oct. 2015, 09:22:26 »
After quite some experiments, I got Mushraider in folder "mushraider" working (together with the Wordpress mainpage of the guild):


location ~* ^/mushraider/app/webroot/.+$ {
       try_files $uri $uri/ /index.php?$uri&$args;
}

location ~ ^/(mushraider)/(.*)? {
    index  index.php;
    set $new_uri /$1/app/webroot/$2;
    try_files $new_uri $new_uri/ /$1/index.php?$args;
}

location ^~ /mushraider/files/ {
    index  index.php;
   rewrite ^/mushraider/(.*)$ /mushraider/app/webroot/$1 break;
}

Without the last file block, graphics were not shown.

Mush

  • Mushraider
  • Administrator
  • Hero Member
  • *****
  • Messages: 768
  • Meh.
    • Voir le profil
    • MushRaider
Re : Admin assets not loading (404)
« Réponse #5 le: 23 oct. 2015, 10:35:57 »
Good to know, thank you
MushRaider - modern raid planner for modern raiders
Me suivre sur  twitter and Google+
Soutenir le projet et me payer une bière =)