Skip to content

Instantly share code, notes, and snippets.

@balinterdi
Created April 1, 2009 12:18
Show Gist options
  • Save balinterdi/88662 to your computer and use it in GitHub Desktop.
Save balinterdi/88662 to your computer and use it in GitHub Desktop.
-rw-r--r-- 1 deploy deploy 10011 Mar 30 19:46 README
-rw-r--r-- 1 deploy deploy 307 Mar 30 19:46 Rakefile
drwxr-xr-x 6 deploy deploy 4096 Mar 27 12:45 app
drwxr-xr-x 5 deploy deploy 4096 Apr 1 12:23 config
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 db
drwxr-xr-x 2 deploy deploy 4096 Mar 30 19:46 doc
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 lib
drwxrwxr-x 2 mongrel deploy 4096 Apr 1 11:28 log
drwxr-xr-x 5 deploy deploy 4096 Mar 27 12:52 public
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 script
drwxr-xr-x 7 deploy deploy 4096 Mar 30 19:46 test
drwxr-xr-x 6 mongrel deploy 4096 Mar 30 19:46 tmp
drwxr-xr-x 3 deploy deploy 4096 Mar 30 19:46 vendor
---
user: mongrel
cwd: /opt/sites/casspeat
log_file: log/mongrel.log
port: "8000"
environment: production
group: mongrel
# address: 127.0.0.0
pid_file: tmp/pids/mongrel.pid
servers: 3
user www-data;
worker_processes 6;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 64;
upstream mongrel {
# This changes from round-robin based to load based. But you need an additional script, see
# http://brainspl.at/articles/2007/11/09/a-fair-proxy-balancer-for-nginx-and-mongrel
# fair;
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
# the server directive is nginx's virtual host directive.
server {
server_name li59-27.members.linode.com;
server_name new.casspeat.com;
listen 80;
client_max_body_size 50M;
root /opt/sites/casspeat;
access_log /var/log/nginx/casspeat.log;
error_log /var/log/nginx/casspeat.error.log;
# page if it exists in the doc root. This is for capistrano's
# disable web task
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
location / {
# needed to forward user's IP address to rails
proxy_set_header X-Real-IP $remote_addr; # needed for HTTPS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
proxy_max_temp_file_size 0;
# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
break;
}
# check for index.html for directory index
# if its there on the filesystem then rewite
# the url to add /index.html to the end of it
# and then break to send it to the next config rules.
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
# this is the meat of the rails page caching config
# it adds .html to the end of the url and then checks
# the filesystem for that file. If it exists, then we
# rewite the url to have explicit .html on the end
# and then send it on its way to the next config rule.
# if there is no file on the fs then it sets all the
# necessary headers and proxies to our upstream mongrels
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://mongrel;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
# root /path/to/your/application/public;
root /opt/sites/casspeat/public;
}
}
}
$ sudo -u mongrel mongrel_rails cluster::start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment