# builds the nginx configuration class RailsPwnage::App::NginxConfig include RailsPwnage::Base # writes the nginx configuration for this server def config_nginx(app_name, instance_name) app_config = RailsPwnage::Config[app_name, instance_name] first_port = app_config[:port0] # Can be specified as comma-separated string or array. if app_config[:dns_name].respond_to? :to_str dns_names = app_config[:dns_name].split(',') else dns_names = app_config[:dns_name] end default_app_port = app_config[:ssl_key] ? 443 : 80 app_port = app_config[:port] || default_app_port nginx_config = File.join(RailsPwnage::Config.path_to(:nginx_configs), app_name + '.' + instance_name) File.open(nginx_config, 'w') do |f| # link to the frontends f << " upstream #{app_name}_#{instance_name} {\n" RailsPwnage::Config.app_frontends(app_name, instance_name).times do |instance| f << " server 127.0.0.1:#{first_port + instance};\n" end f << " }\n\n" # server configuration -- big and ugly f << <