Skip to content

Instantly share code, notes, and snippets.

@rottmanj
Created September 13, 2012 23:58
Show Gist options
  • Save rottmanj/3718762 to your computer and use it in GitHub Desktop.
Save rottmanj/3718762 to your computer and use it in GitHub Desktop.
nginx task
after "deploy:setup", :nginx
namespace :nginx do
desc "Create nginx.conf and generates nginx.conf symlink"
task :default, :roles => :app do
current_ip = capture("curl http://169.254.169.254/latest/meta-data/public-ipv4")
# CREATES THE BASE NGINX CONFIG
config_content = from_template("config/templates/nginx.conf.erb")
put config_content, "#{shared_path}/config/nginx.conf"
run "sudo ln -nfs #{shared_path}/config/nginx.conf #{nginx_conf_path}"
# CREATES THE VHOST NGINX CONFIG
config_content = from_template("config/templates/vhost.erb")
put config_content, "#{shared_path}/config/#{webistrano_stage}"
run "sudo ln -nfs #{shared_path}/config/#{webistrano_stage} #{nginx_conf_path}/sites-enabled/#{webistrano_stage}"
#upload the cert file
upload("#{RAILS_ROOT}/config/certificates/#{certificate_name}.crt", "#{shared_path}/certs/#{certificate_name}.crt")
#upload the key file
upload("#{RAILS_ROOT}/config/certificates/#{certificate_name}.key", "#{shared_path}/certs/#{certificate_name}.key")
run "chmod 600 #{shared_path}/certs/#{certificate_name}.key"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment