Skip to content

Instantly share code, notes, and snippets.

@jlove4m
Created July 31, 2016 14:06
Show Gist options
  • Save jlove4m/77d99dd81426dbd313f1f00b9f438bf6 to your computer and use it in GitHub Desktop.
Save jlove4m/77d99dd81426dbd313f1f00b9f438bf6 to your computer and use it in GitHub Desktop.
Basic nginx config for rails app
#/etc/nginx/nginx.conf - linux (debian/ubuntu)
#/usr/local/etc/nginx/nginx.conf
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
client_max_body_size 100M;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging Settings - you can define these on a per server basis in your server blocks
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Gzip Settings
gzip on;
gzip_disable "msie6";
include /etc/nginx/proxy_params;
include /etc/nginx/conf.d/*.conf;
#include wherever you keep your server definitions, often in sites-enabled.
}
upstream rails_socket {
server unix:/path/to/app/environment/current/tmp/sockets/sock.1;
server unix:/path/to/app/environment/current/tmp/sockets/sock.2;
#ngninx has a bunch of directives/options you can use here
}
server {
listen 80 default_server; #you can also do SSL
server_name mydomain.tld;
access_log /path/to/logdir/nginx/mydomain.tldaccess.log; #linux - /var/log/nginx, others are different
error_log /path/to/logdir/nginx/mydomain.tld.error.log;
#locations are evaluated in order, keep that in mind
location /assets {
root /path/to/app/environment/current/assets;
}
location / {
proxy_pass http://rails_socket;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment