Skip to content

Instantly share code, notes, and snippets.

@keighl
Created March 1, 2012 16:04
Show Gist options
  • Save keighl/1950820 to your computer and use it in GitHub Desktop.
Save keighl/1950820 to your computer and use it in GitHub Desktop.
NGINX Configuration / Passenger + Rails
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /home/USER/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11;
passenger_ruby /home/USER/.rvm/wrappers/ruby-1.9.2-p290/ruby;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Rewrite !
server {
listen 80;
server_name example.com;
rewrite ^/(.*) http://www.example.com$request_uri? permanent;
}
server {
listen 80;
server_name www.example.com;
root /home/USER/example.com/public;
rails_env production;
client_max_body_size 10M;
passenger_friendly_error_pages on;
passenger_enabled on;
location ~ ^/(assets)/ {
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
}
# Default
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment