meenie / munee

Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation
https://munee.herokuapp.com/
MIT License
833 stars 92 forks source link

nginx rewrite #4

Closed jrahmy closed 11 years ago

jrahmy commented 11 years ago

Any idea on an nginx rewrite rule?

meenie commented 11 years ago

Maybe try this? I've never used nginx, I've only just Googled a couple of articles and kind of guessed how it should work haha. Let me know how it goes! That way I can add it into the documentation :+1:

location / {
    rewrite ^(.*\.(?:css|less|scss|js|coffee|jpg|png|gif|jpeg))$ munee.php?files=/$1 last;
}
jrahmy commented 11 years ago

Tried that earlier via some converter tool, was redirecting fine but then it wouldn't pass the PHP file to fpm for parsing so it would just get downloaded.. thanks though!

meenie commented 11 years ago

Well crap! Hopefully this can be figured out so I can put the instructions in the documentation. I'd rather not exclude nginx uses if at all possible. If you do come across a solution, please let me know.

As for a work around for now, try following the "Using Munee without a .htaccess rule" instruction and let me know if that works.

jrahmy commented 11 years ago

Yeah that's how I've been using it since posting this and it's been working like a charm :) Will try to play around a bit more with rewrites tomorrow, I'll post a solution if I find one.

Also thanks for munee, I liked the idea of Assetic but its use was a bit complicated for my needs.. this has all the features I need and nothing more, and it's easy to use!

meenie commented 11 years ago

I appreciate you tinkering with it and trying to find a solution.

Your feedback has made my day :+1: This is the exact reason why I built Munee in the first place :). My designers needed something they can drop in place without much fuss and it just works.

I'll close this question for now. If you find anything new, just open up a new one I suppose :).

jrahmy commented 11 years ago

Finally had the time to figure out regex.. this works :smiley: rewrite ^(.+.(css|less|scss|js|coffee|gif|jpe?g|png))$ /munee.php?files=/$1 break;

meenie commented 11 years ago

Awesome! Thanks for that :-). I'll put it into the Readme ASAP.

Kinamo commented 8 years ago

Hi,

Thanks for the excellent library :-) We are also using NGinx and had to change the regex a bit, probably depends on the configuration, but here's the block we are using, both with rewrite for index.php as well as rewrite for asset files to Munee. Hope this helps someone:

index   index.php;

location ~ ^(.+\.(css|less|scss|js|coffee|gif|jpe?g|png))$ {
        rewrite ^(.+)$ /munee.php?files=$1 last;
}

location / {
        try_files $uri $uri/ @rewrite;
}

location @rewrite {
       rewrite ^/.*$ /index.php last;
}

 location ~ \.php$ {
       include fastcgi_params;
       ... and so on...
}

Take care!

Kinamo