Sha256: 311cd305566646d284df2291b7b93f3553f0fb7105736145a210cec09642b3af
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
namespace :deploy do namespace :nginx do desc 'Generate Nginx configuration' task :generate_config do Dir.mkdir('tmp') unless Dir.exist?('tmp') app_dir = fetch(:deploy_to) app_name = fetch(:app_name) server_names = Array(fetch(:server_names)) server_names << "#{app_name}.live.lkp.primelabs.se" https_port = ":443" if fetch(:use_https) conf = File.open('tmp/site.conf', 'w') conf << %Q{ upstream #{app_name} { server unix:/tmp/#{app_name}.sock; } server { listen 80; server_name #{server_names.join(' ')}; root #{app_dir}/current/public; try_files /system/maintenance.html $uri @app; location /assets { expires 1h; } location /favicon.ico { expires 1h; } location /robots.txt { expires 1h; } expires -1; location @app { expires off; proxy_pass http://#{app_name}; proxy_redirect off; proxy_set_header Host $host#{https_port}; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }\n} conf.close end desc 'Upload Nginx configuration' task :upload_config do on roles(:app) do app_name = fetch(:app_name) upload! 'tmp/site.conf', "/etc/nginx/sites-available/#{app_name}.conf" end end desc 'Symlink Nginx configuration' task :enable_config do on roles(:app) do app_name = fetch(:app_name) execute :ln, '-nfs', "/etc/nginx/sites-available/#{app_name}.conf", "/etc/nginx/sites-enabled/#{app_name}.conf" end end desc 'Reload Nginx' task :reload do on roles(:app) do execute :sudo, 'service', 'nginx', 'reload' end end end end
Version data entries
5 entries across 5 versions & 1 rubygems