Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

CombineAssets on nginx

$Configuration['Garden']['CombineAssets'] = TRUE;

i have tried combined assets on NGINX but not showing the stylesheet im using bootstrap 3.1


the link is not present

it's not showing any cache

Did anyone of you guys are running on nginx and got combined assets to work ? it's very helpful since combining css would greatly help the payload.

Answers

  • show your server rules please.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    utility is not a physical location so you need to tell nginx what to do as css is served as static content typically.

    Alternatively you can use my plugin

    http://vanillaforums.org/addon/consolidate-plugin-0.1.6b

    Advantages:

    • It provides the actual static resources directly.
    • By default it doesn't combine in too few files, but in reasonable chunks to avoid the domino effect.
    • it is customizable by cascading regex pattens (advanced).

    If you make changes to theme, plugin, without updating version, you will need to remember to click the clear cache button, bu this is not a biggie.

    grep is your friend.

  • fr3em1ndfr3em1nd ✭✭
    edited May 2014

    hi @x00‌
    nothing fancy. i've been using this config for a long time. is there something to add?

    server {
        listen xxxxx:80;
    
        root /home/xxxxx.co/web;
        index index.php default.php index.html index.htm;
        autoindex off;
    
        server_name  www.xxxxx.xxx
    
    
        location / {
    
            try_files $uri $uri/ /index.php?p=$uri&$args;
    
            rewrite ^/(.+)$ /index.php?p=$1 last;
    
        }
    
    
         location /utility/ {
            rewrite ^/(.+)$ /index.php?p=$1 last;
        }
    
    
         location /uploads/FileUpload/ {
           root /home/xxxxx/web/uploads/FileUpload/;
        }
    
    
    
    
    
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
    
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    
            # With php5-cgi alone:
            #fastcgi_pass 127.0.0.1:9000;
    
    
            # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
        }
    
    
        ############# VANILLA CONFIGS
    
        location ~* ^/uploads/.*.(html|htm|shtml|php)$ {
        alias /home/xxxxx/web/uploads/;
        autoindex on;
    
          types { }
          default_type text/plain;
      }
    
    
      location ~ /\. { access_log off; log_not_found off; deny all; }
      location ~ ~$ { access_log off; log_not_found off; deny all; }
      #location = /robots.txt { access_log off; log_not_found off; }
      location ^~ favicon { access_log off; log_not_found off; }
      location ^~ /conf/ { internal; }
    
       location ~* \.(js|css|png|bmp|jpg|jpeg|gif|ico|eot|woff|ttf|svg|swf|apk|txt|zip|xml)$ {
          expires max;
          log_not_found off;
      }
    
    
    }
    
  • consolidate got this error on default installation for 2.1 rc1

  • fixed the consolidate error before the error line put:

    if(is_array($Filename) )

  • fr3em1ndfr3em1nd ✭✭
    edited May 2014

    lots of problems on consolidate even the most important "quote" feature goes to new comment page when clicked and not stay on parent window

  • x00x00 MVP
    edited May 2014

    @fr3em1nd said:
    fixed the consolidate error before the error line put:

    if(is_array($Filename) )

    that is incorrect becuase $Filename is the needle not the haystack. Good catch though that check doesn't need to be there.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    @fr3em1nd said:
    lots of problems on consolidate even the most important "quote" feature goes to new comment page when clicked and not stay on parent window

    Check to see what file have been created. You are not deferring js to bottom are you? Don't do that it is for experts only. I presume you disabled CombineAssets

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    Your server rules are lackluster, but

    location /utility/ {
    rewrite ^/(.+)$ /index.php?p=$1 last;
    }
    

    is redundant. take that out. I defiantly recommend putting the php handler first.

    grep is your friend.

  • this works by chance the second line won't be reached.

    location / {
    try_files $uri $uri/ /index.php?p=$uri&$args;
    rewrite ^/(.+)$ /index.php?p=$1 last;
    }
    

    replace with

    location / {
        try_files $uri $uri/ @forum;
    }
    
    location @forum {
        rewrite ^(.+)$ /index.php?p=$1 last;
    }
    

    like i said php handler should be before this.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    Just tried it an works fine. Combine assets should be in /cache/css if not you haven't set permissions correctly, you may need to create this folder.

    that will also be the problem with consolidate.

    grep is your friend.

  •  location /uploads/FileUpload/ {
    root /home/xxxxx/web/uploads/FileUpload/;
    }
    

    is there a reason for this? it seem redundant to me, unless it really is detached.

    grep is your friend.

  • x00x00 MVP
    edited May 2014

    I've updated Consolidate

    http://vanillaforums.org/addon/consolidate-plugin

    read the instructions regarding creating the folder Consolidate and file permissions, then you may need to clear

    grep is your friend.

  • R_JR_J Ex-Fanboy Munich Admin

    @x00 said:
    this works by chance the second line won't be reached.

    location / {
    try_files $uri $uri/ /index.php?p=$uri&$args;
    rewrite ^/(.+)$ /index.php?p=$1 last;
    }
    

    replace with

    location / {
        try_files $uri $uri/ forum;
    }
    
    location forum {
        rewrite ^(.+)$ /index.php?p=$1 last;
    }
    

    like i said php handler should be before this.

    I've toyed around with nginx a bit and often found that location forum... part, but found the one liner try_files $uri $uri/ /index.php?p=$uri&$args; much more elegant. Could you tell me why you do not prefer it?

  • x00x00 MVP
    edited May 2014

    you don't have to use an alias, but say for instance the folder is in a subdomian, you are not using the whole $uri&$args;. The rewrite ^/(.+)$ /index.php?p=$1 last; isn't reached anyway.

    args would be passed automatically to the alias. With a rewrite there is no need to explicitly tag them on.

    grep is your friend.

  • thanks for your help guys :) the result is awesome :) consolidate is the best :)

  • @fr3em1nd

    if you also made the suggested changes to nginx rules with x00's recs.

    can you report with all changes made.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine

    the only nginx rules i removed is:

         location /utility/ {
            rewrite ^/(.+)$ /index.php?p=$1 last;
        }
    

    the other recommendations are not applicable on my end since i'm using vanilla as base script on my domain.

Sign In or Register to comment.