Open erkolson opened 8 years ago
Erik,
I am sorry. I forgot to commit and push my last changes.
Lavorn Smalls
On Mon, Aug 8, 2016 at 11:19 AM, Erik notifications@github.com wrote:
I do not see weather.conf.erb or bing.conf.erb in the repo?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/biglds/nginx_example/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-JiZAQ9fcdhi_DUcGZhGmXFBRiTFLmks5qd0j7gaJpZM4JfJyO .
Thanks.
I attempted to run the cookbook and had some issues.
I first ran berks init
in the cookbook to create the test kitchen framework.
From that point I could execute the code with kitchen converge
(I have also previously installed Vagrant and VirtualBox)
I then had to make several changes to get the cookbook to compile, converge, and have nginx successfully start. These are the changes, (I tried to push a branch to this repo but was not permitted and did not want to take the time to fork and apply my changes there. So sorry for the annoying formatting, this is my diff):
diff --git a/.kitchen.yml b/.kitchen.yml
index 0ae805f..66bd017 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -7,10 +7,12 @@ provisioner:
platforms:
- name: ubuntu-14.04
- - name: centos-7.2
+ # - name: centos-7.2
suites:
- name: default
run_list:
- - recipe[test::default]
+ - recipe[nginx_proxy::default]
+ - recipe[nginx_proxy::test]
attributes:
+ FQDN: localhost
diff --git a/metadata.rb b/metadata.rb
index ad341d9..65dfbc7 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -4,7 +4,7 @@ maintainer_email 'lavorns@gmail.com'
license 'All rights reserved'
description 'Installs/Configures nginx_proxy'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version '0.1.0'
+version '0.1.1'
-depends 'nginx'
\ No newline at end of file
+depends 'nginx'
diff --git a/recipes/default.rb b/recipes/default.rb
index 579c0f7..401a03c 100644
--- a/recipes/default.rb
+++ b/recipes/default.rb
@@ -8,5 +8,5 @@
#
-include_recipe 'install'
-include_recipe 'proxy_pass'
\ No newline at end of file
+include_recipe 'nginx_proxy::install'
+include_recipe 'nginx_proxy::proxy_pass'
diff --git a/recipes/proxy_pass.rb b/recipes/proxy_pass.rb
index 9bb258c..eec5909 100644
--- a/recipes/proxy_pass.rb
+++ b/recipes/proxy_pass.rb
@@ -22,10 +22,11 @@ directory "#{node['nginx']['dir']}/conf.d" do
end
+chef_gem 'colorize'
+
# Code to ensure nginx restarts
ruby_block 'killall_nginx' do
block do
-
out = %x(killall nginx)
unless $?.to_i == 0
require 'colorize'
@@ -37,10 +38,15 @@ ruby_block 'killall_nginx' do
action :nothing
end
+env = {
+ 'DomainName' => 'dont.forget.me.com'
+}
+
# Place proxy config file in proper directory
template "#{node['nginx']['dir']}/conf.d/bing.conf" do
source 'bing.conf.erb'
mode 0644
+ variables(:env => env)
notifies :restart, 'service[nginx]', :delayed
notifies :run, 'ruby_block[killall_nginx]', :immediately
action :create
@@ -49,7 +55,8 @@ end
template "#{node['nginx']['dir']}/conf.d/weather.conf" do
source 'weather.conf.erb'
mode 0644
+ variables(:env => env)
notifies :restart, 'service[nginx]', :delayed
notifies :run, 'ruby_block[killall_nginx]', :immediately
action :create
-end
\ No newline at end of file
+end
diff --git a/recipes/test.rb b/recipes/test.rb
new file mode 100644
index 0000000..9dc7eb6
--- /dev/null
+++ b/recipes/test.rb
@@ -0,0 +1,2 @@
+
+package "curl"
diff --git a/templates/default/bing.conf.erb b/templates/default/bing.conf.erb
index 6fef7d4..f259eaa 100644
--- a/templates/default/bing.conf.erb
+++ b/templates/default/bing.conf.erb
@@ -2,7 +2,7 @@ server {
server_name <%= node[:FQDN] %>
alias <%= @env["DomainName"] %>
listen 80;
- ssl on;
+ ssl off;
client_max_body_size 0;
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
@@ -17,4 +17,4 @@ server {
}
access_log /var/log/nginx/<%= node[:FQDN] %>-access.log;
error_log /var/log/nginx/<%= node[:FQDN] %>-error.log;
-}
\ No newline at end of file
+}
diff --git a/templates/default/weather.conf.erb b/templates/default/weather.conf.erb
index 06d3478..916be8b 100644
--- a/templates/default/weather.conf.erb
+++ b/templates/default/weather.conf.erb
@@ -2,7 +2,7 @@ server {
server_name <%= node[:FQDN] %>
alias <%= @env["DomainName"] %>
listen 80;
- ssl on;
+ ssl off;
client_max_body_size 0;
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;
@@ -17,4 +17,4 @@ server {
}
access_log /var/log/nginx/<%= node[:FQDN] %>-access.log;
error_log /var/log/nginx/<%= node[:FQDN] %>-error.log;
-}
\ No newline at end of file
+}
At this point, nginx is running, but it does not succeed in passing the following requests:
curl 'http://localhost/bing/search?q=hello'
curl 'http://localhost/weather/today/l/USGA0028:1:US'
I do not see
weather.conf.erb
orbing.conf.erb
in the repo?