Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
unicorn + nginx setup + ssl
unicorn.rb
-----------------------------------
application = "jarvis"
remote_user = "vagrant"
env = ENV["RAILS_ENV"] || "development"
RAILS_ROOT = File.join("/home", remote_user, application)
worker_processes 8
timeout 30
preload_app true
working_directory RAILS_ROOT
listen File.join(RAILS_ROOT, "tmp/unicorn.sock"), :backlog => 64
pid_path = File.join(RAILS_ROOT, "tmp/pids/unicorn.pid")
pid pid_path
stderr_path File.join(RAILS_ROOT, "log/unicorn-err.log")
stdout_path File.join(RAILS_ROOT, "log/unicorn-err.log")
before_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
old_pid_path = "#{pid_path}.oldbin"
if File.exists?(old_pid_path) && server.pid != old_pid_path
begin
Process.kill("QUIT", File.read(old_pid_path).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
end
# worker processes http://devmull.net/articles/unicorn-resque-bluepill
# rails_env = ENV['RAILS_ENV'] || 'production'
# worker.user('app', 'app') if Process.euid == 0 && rails_env == 'production'
end
nginx
----------------------------------
upstream dev.jarvis.com {
server unix:/home/vagrant/jarvis/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 443 default;
ssl on;
ssl_certificate /home/vagrant/ssl/server.cer;
ssl_certificate_key /home/vagrant/ssl/server.key;
server_name dev.jarvis.com;
root /home/vagrant/jarvis/public;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_redirect off;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://dev.jarvis.com;
}
error_page 502 503 /maintenance.html;
error_page 500 504 /500.html;
keepalive_timeout 5;
}
@johnantoni
Owner

works like a dream, not built for deployments as i was just testing it out on my dev box but that wouldn't take long

@felipeclopes

Cool! Do you have your deployment version? I'm having headaches trying to make this ssl works with nginx + unicorn using rubber scripts. If you have your unicorn and nginx configs for me it would be great!

Tnx!

@martinstreicher

I am looking for a Unicorn + nginx + http > https example.

@r00takaspin

Thank you!

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.