From a9cad6683ad51a7ecd6edfafbb2ccaf285c39971 Mon Sep 17 00:00:00 2001 From: amine Date: Wed, 3 Dec 2014 17:28:04 +0100 Subject: [PATCH] rajout de la variable protocol --- Vagrantfile | 57 ++++++++++++++++++++++++++++++-- templates/default/nginx.conf.erb | 4 +-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 574149b..68f6b7f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -15,6 +15,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.berkshelf.enabled = true config.berkshelf.berksfile_path = 'Berksfile' + config.vm.network "private_network", ip: "192.168.50.4" config.vm.provider 'virtualbox' do |vbox| vbox.customize ['modifyvm', :id, '--memory', 1024] vbox.customize ['modifyvm', :id, '--cpus', 2] @@ -25,7 +26,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| nginx: { :servers => { :'sugar.pmsipilot.com' => { - :port => 8888, + :port => 80, :upstreams => { :sugar => { :ip => 'sugar', @@ -36,14 +37,64 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| { :path => '/', :alias => '/sugar', + :protocol => 'http', :upstream => :sugar + + } + ] + }, + :'demobi.pmsipilot.com' => { + :port => 80, + :upstreams => { + :demobi => { + :ip => 'srv-demo-pbi1', + :port => 443 + + } + }, + :locations => [ + { + + :path => '/', + :alias => '/', + :protocol => 'https', + :upstream => 'srv-demo-pbi1' + + } + ] + + + + }, + :'demo.pmsipilot.com' => { + + :port => 80, + :upstreams => { + :demo => { + :ip => 'srv-demo', + :port => 80 + + + } + + }, + + + :locations => [ + + { + :path => '/', + :protocol => 'http', + :upstream => 'srv-demo' } - } + + ] + } } } - + } chef.run_list = %w( recipe[nginx] recipe[nginx-config] diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index 2f29380..00be51b 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -12,8 +12,8 @@ server { <% @server['locations'].each do |location_def| %> location <%= location_def['path'] %> { - proxy_pass http://<%= location_def['upstream'] %><%= location_def['alias'] %>/; - proxy_redirect http://<%= location_def['upstream'] %><%= location_def['alias'] %>/ <%= location_def['alias'] %>/; + proxy_pass <%= location_def['protocol'] %>://<%= location_def['upstream'] %><%= location_def['alias'] %>/; + proxy_redirect <%= location_def['protocol'] %>://<%= location_def['upstream'] %><%= location_def['alias'] %>/ <%= location_def['alias'] %>/; proxy_set_header Host $proxy_host; proxy_set_header X-Real-IP $remote_addr; }