Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Configure nginx to server static gzipped content #72

Open
yourivdlans opened this issue Jul 23, 2014 · 6 comments
Open

Configure nginx to server static gzipped content #72

yourivdlans opened this issue Jul 23, 2014 · 6 comments

Comments

@yourivdlans
Copy link
Contributor

At this time the nginx configuration does not include a config for serving static gzip content. See the rails guides for the actual config:

http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression

@michiels
Copy link
Member

Thanks for pointing this out @yourivdlans! This will probably involve a bit more in the Chef recipes for the passenger stack because passenger takes care of serving assets as static files itself. To work around this, we probably need something like the following sample.

In this sample, we will try to load the URL first via try_files so it will use the location ~ ^/(assets)/ directive. If it can't find the file, it will try to run it from passenger.

server {
  ...
  root /u/apps/railsapp/current/public;
  try_files $uri @passenger;

  location @passenger {
    passenger_enabled on;
  }

  location ~ ^/(assets)/  {
    root /u/apps/railsapp/current/public;
    gzip_static on; # to serve pre-gzipped version
    expires max;
    add_header Cache-Control public;
  }
  ...
}

@michiels michiels changed the title Serving of static gzipped content Configure nginx to server static gzipped content Aug 7, 2014
@jvanbaarsen
Copy link
Contributor

Looks like we also need to pass an option to Passenger when compiling with nginx
From the rails docs:

If you're compiling nginx with Phusion Passenger you'll need to pass that option when prompted.

@michiels
Copy link
Member

@jvanbaarsen We don't compile passenger or nginx. Passenger and nginx is installed form the Phusion deb repositories in the Rails cookbook.

@jvanbaarsen
Copy link
Contributor

@michiels Ok, so that means we cant pass in the flag for gzip content? or is that passed in by default?

@michiels
Copy link
Member

@jvanbaarsen It's passed by default. I don't think we need to change anything in how we install passenger itself for this issue.

@jvanbaarsen
Copy link
Contributor

@michiels Ok thanks!

@ghost ghost self-assigned this Nov 27, 2014
@ghost ghost mentioned this issue Jan 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants