Skip to content

Instantly share code, notes, and snippets.

@skojin
Created February 16, 2011 14:33
Show Gist options
  • Save skojin/829459 to your computer and use it in GitHub Desktop.
Save skojin/829459 to your computer and use it in GitHub Desktop.
nginx rails configuration, with assets expiration
server {
listen 80;
server_name APP.com;
rewrite ^/(.*) http://www.APP.com/$1 permanent;
}
server {
listen 80;
server_name www.APP.com;
root /home/USER/sites/APP/current/public;
passenger_enabled on;
passenger_min_instances 1;
passenger_friendly_error_pages off;
client_max_body_size 4M;
gzip on;
gzip_comp_level 3;
gzip_min_length 1000;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6]\.";
# expires headers only if have ?123 timestamp at end, with extra check for js only in javascripts folder, to allow actions with .js format specification
location ~* (\.ico|\.css|\.gif|\.jpe?g|\.png|javascripts.+\.js) {
if ($args ~* [0-9]+$) {
expires max;
access_log off;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment