user www-data; worker_processes 4; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; accept_mutex off; # "on" if nginx worker_processes > 1 } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; tcp_nopush off; keepalive_timeout 10; gzip on; gzip_proxied any; gzip_min_length 1400; gzip_vary on; gzip_http_version 1.1; gzip_disable "MSIE [1-6]\."; gzip_types text/plain text/css image/png image/gif image/jpeg application/x-javascript text/xml application/xml application/xml+rss text/javascript; # Unicorn upstream domain_server { # This is the socket we configured in unicorn.rb server unix:/var/local/apps/domain/tmp/sockets/unicorn.sock fail_timeout=0; } # Redirect server { listen 80; server_name www.domain.com.br; rewrite ^(.*) http://domain.com.br$1 permanent; } # Application server { listen 80; server_name domain.com.br; client_max_body_size 4G; keepalive_timeout 5; root /var/local/apps/domain/public; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://domain_server; break; } #auth_basic "Acesso restrito"; #auth_basic_user_file htpasswd; } error_page 500 502 503 504 /500.html; location = /500.html { root /var/local/apps/domain/public; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 30d; log_not_found off; } } # Assets server { listen 80 default; #server_name domain.com.br; server_name ~^assets%d.domain.com.br; root /var/local/apps/domain/public; location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 30d; log_not_found off; } } }