Skip to content

Instantly share code, notes, and snippets.

@vdv
Last active October 2, 2015 20:18
Show Gist options
  • Save vdv/2313275 to your computer and use it in GitHub Desktop.
Save vdv/2313275 to your computer and use it in GitHub Desktop.
nginx config with unicorn
upstream rails_app_upstream {
server unix:/home/deployer/projects/rails_app/shared/tmp/sockets/unicorn.socket fail_timeout=0;
}
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name localhost my_server.ru;
root /home/deployer/projects/rails_app/current/public;
index index.html index.htm;
access_log /home/deployer/projects/rails_app/shared/log/nginx-access.log;
error_log /home/deployer/projects/rails_app/shared/log/nginx-error.log;
client_max_body_size 10m;
client_body_buffer_size 128k;
location / {
try_files $uri/index.html $uri.html $uri @rails_app;
}
location @rails_app{
proxy_pass http://rails_app_upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location ~* ".*?\.(ico|css|js|gif|jpg|jpeg|png|doc|pdf)(\?[0-9]*)?$" {
expires 24h;
#expires max;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment