Skip to content

Instantly share code, notes, and snippets.

@webgago
Created June 28, 2011 09:29
Show Gist options
  • Save webgago/1050802 to your computer and use it in GitHub Desktop.
Save webgago/1050802 to your computer and use it in GitHub Desktop.
nginx config
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log;
pid /opt/nginx/logs/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
client_max_body_size 25m;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_min_length 512;
gzip_buffers 256 8k;
gzip_comp_level 3;
gzip_proxied any;
gzip_types image/bmp application/json text/plain text/css application/x-javascript application/xml application/xhtml+xml;
server_tokens off;
keepalive_timeout 35;
include /opt/nginx/conf/mime.types;
reset_timedout_connection on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 20 256k;
charset utf-8;
log_format main '[$host] $remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio" $request_filename';
access_log /var/log/nginx/access.log main;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=unicorn:200m max_size=500m;
upstream idealjob {
server unix:/home/rails/idealjob.ru/shared/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name idealjob.ru;
rewrite ^(.*)$ http://www.idealjob.ru$1 permanent;
}
server{
listen 80;
server_name *.assets.idealjob.ru;
location ~* ^\/(stylesheets|javascripts|system|images|img).*\.(jpg|jpeg|gif|png|css|js)$ {
root /home/rails/idealjob.ru/current/public;
access_log off;
expires 30d;
}
root /home/rails/idealjob.ru/current/public;
}
server {
listen 80;
server_name *.idealjob.ru;
root /home/rails/idealjob.ru/current/public;
# allow requests for images, js, css, and icons to go through
# even if cap has been used to disable the site
if ($request_filename ~* /(img|images|javascripts|stylehseets)/) { break; }
if ($request_filename ~* \.ico$) { break; }
# for cap's deploy:web:disable task
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
break;
}
client_max_body_size 80M;
keepalive_timeout 5;
try_files $uri $uri.html @idealjob;
location @idealjob {
if ( $http_user_agent ~ "MSIE 6\.0" ) { rewrite ^.*$ /ie/ie6.html; break; }
proxy_pass http://idealjob;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
location ~* ^\/(system|images|img).*\.(jpg|jpeg|gif|png|)$ {
root /home/rails/idealjob.ru/current/public;
access_log off;
expires 30d;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/rails/idealjob.ru/current/public;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment