Skip to content

@tbbooher /nginx.conf
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
worker_processes 1;
user www-data www-data;
pid /var/run/nginx.pid;
error_log /var/log/nginx/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/nginx.access.log combined;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/html text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
upstream unicorn_polco {
server unix:/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
client_max_body_size 1G;
server_name localhost;
root /home/passenger/polco/current/public;
access_log /var/log/nginx/server.access.log;
error_log /var/log/nginx/server.error.log;
location / {
try_files $uri/index.html $uri.html $uri @unicorn;
#try_files $uri @unicorn;
}
location @unicorn {
# an HTTP header important enough to have its own Wikipedia entry:
# http://en.wikipedia.org/wiki/X-Forwarded-For
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# enable this if and only if you use HTTPS, this helps Rack
# set the proper protocol for doing redirects:
# proxy_set_header X-Forwarded-Proto https;
# pass the Host: header from the client right along so redirects
# can be set properly within the Rack application
proxy_set_header Host $http_host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
# set "proxy_buffering off" *only* for Rainbows! when doing
# Comet/long-poll stuff. It's also safe to set if you're
# using only serving fast clients with Unicorn + nginx.
# Otherwise you _want_ nginx to buffer responses to slow
# clients, really.
# proxy_buffering off;
proxy_pass http://unicorn_polco;
}
# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
# location ~* \.(?:ico|css|js|gif|jpe?g|png|html|htm)$ {
# # Some basic cache-control for static files to be sent to the browser
# expires max;
# add_header Pragma public;
# add_header Cache-Control "public, must-revalidate, proxy-revalidate";
# }
# remove the robots line if you want to use wordpress' virtual robots.txt
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
# this prevents hidden files (beginning with a period) from being served
location ~ /\. { access_log off; log_not_found off; deny all; }
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/passenger/polco/current/public;
}
}
}
worker_processes 2
base_dir = "/home/passenger/polco/current"
shared_path = "/home/passenger/polco/shared"
working_directory base_dir
# This loads the application in the master process before forking
# worker processes
# Read more about it here:
# http://unicorn.bogomips.org/Unicorn/Configurator.html
preload_app true
# we destroy all workers who are taking too long
timeout 30
# This is where we specify the socket.
# We will point the upstream Nginx module to this socket later on
listen "/tmp/sockets/unicorn.sock", :backlog => 64
pid "#{shared_path}/pids/unicorn.pid"
# Set the path of the log files inside the log folder of the testapp
stderr_path "#{shared_path}/log/unicorn.stderr.log"
stdout_path "#{shared_path}/log/unicorn.stdout.log"
before_fork do |server, worker|
# This option works in together with preload_app true setting
# What is does is prevent the master process from holding
# the database connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
# Here we are establishing the connection after forking worker
# processes
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
@tbbooher
Owner

the error is:

2011/04/18 15:23:41 [error] 11907#0: *4 connect() to unix:/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 71.191.237.168, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/sockets/unicorn.sock:/", host: "tacitus"
2011/04/18 15:23:42 [error] 11907#0: *4 connect() to unix:/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 71.191.237.168, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/sockets/unicorn.sock:/", host: "tacitus"

@blanchma

Someone find a solution to this error ?

@tbbooher
Owner

yes, i got this working -- but this was awhile ago, but it looks odd http://unix:/tmp

@tbbooher
Owner

i could send you my new config files if that would help

@blanchma
@mattboldt

Any final solution to this? Restarting Unicorn works, but then it seems to randomly go down again after requesting a new URL. Same connection refused error.

@sebastialonso

Also reporting same issue. Any updates? It's been 3 months since last reply.

@kahboom

Having this same issue..

@blevonius-mdsol

Any solutions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.