Skip to content

Instantly share code, notes, and snippets.

@acidlabs-snippets
Created October 1, 2012 14:21
Show Gist options
  • Save acidlabs-snippets/3812072 to your computer and use it in GitHub Desktop.
Save acidlabs-snippets/3812072 to your computer and use it in GitHub Desktop.
nginx config for thin #server #nginx #thin
upstream app_name {
server 127.0.0.1:4000; #port examples
server 127.0.0.1:4001;
}
server {
server_name example.com;
listen 80;
access_log <acces_log_path>;
error_log <error_log_path;
root root_path; # rails public folder
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 1000;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://app_name;
break;
}
}
}
user nginx;
worker_processes 5;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 5000;
#gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment