Skip to content

Instantly share code, notes, and snippets.

@nkokkos
Created May 30, 2013 09:50
Show Gist options
  • Save nkokkos/5676849 to your computer and use it in GitHub Desktop.
Save nkokkos/5676849 to your computer and use it in GitHub Desktop.
This is an nginx configuration file for serving 2 or more rails applications at their own suburi using the passenger gem. That is, if you have a server http://myserver.com and you want to serve your app at http://myserver.com/app1 and your app2 at http://myserver.com/app2
#/opt/nginx/conf/nginx.conf
user nginx;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.3;
passenger_ruby /usr/local/bin/ruby;
passenger_max_pool_size 10;
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
sendfile on;
tcp_nopush on;
keepalive_timeout 65s;
gzip on;
client_max_body_size 25m;
server {
listen 80;
server_name myserver.com;
client_max_body_size 25m;
root /opt/nginx/html;
error_page 404 /404.html;
error_page 413 /413.html;
passenger_enabled on;
rails_env production;
passenger_base_uri /app1;
passenger_base_uri /app2;
location ~ ^/(/assets/) {
root /home/linuxuser/deploy_app1/app1/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location ~ ^/(/assets)/ {
root /home/linuxuser/deploy_app2/app2/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment