Skip to content

Instantly share code, notes, and snippets.

@jeevandongre
Created August 26, 2013 09:29
Show Gist options
  • Save jeevandongre/6339629 to your computer and use it in GitHub Desktop.
Save jeevandongre/6339629 to your computer and use it in GitHub Desktop.
Nginx.conf
worker_processes 2;
user ubuntu ubuntu; # for systems with "nobody" as a group instead
# Feel free to change all paths to suite your needs here, of course
pid /etc/nginx/nginx.pid;
error_log /var/log/nginx/nginx.error.log;
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # "on" if nginx worker_processes > 1
# use epoll; # enable for Linux 2.6+
# use kqueue; # enable for FreeBSD, OSX
}
http {
# nginx will find this file in the config directory set at nginx build time
include mime.types;
# fallback in case we can't determine a type
default_type application/octet-stream;
# click tracking!
access_log /var/log/nginx/nginx.access.log combined;
# you generally want to serve static files with nginx since neither
# Unicorn nor Rainbows! is optimized for it at the moment
sendfile on;
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
tcp_nodelay off; # on may be better for some Comet/long-poll stuff
client_max_body_size 2M;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
# gzip_types text/plain text/html text/xml text/css
# text/comma-separated-values
# text/javascript application/x-javascript
# application/atom+xml;
# this can be any application server, not just Unicorn/Rainbows!
upstream app_server {
# for UNIX domain socket setups:
#server unix:/path/to/.unicorn.sock fail_timeout=0;
# for TCP setups, point these to your backend servers
# server 192.168.0.9:8080 fail_timeout=0;
}
server {
keepalive_timeout 5;
server_name app_name;
# path for static files
root /path/to/app;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /path/to/the/app;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment