Support IPv6 resolvers in nginx config
authorTom Hughes <tom@compton.nu>
Tue, 16 Dec 2014 15:57:24 +0000 (15:57 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 16 Dec 2014 16:01:14 +0000 (16:01 +0000)
cookbooks/tilecache/recipes/default.rb
cookbooks/tilecache/templates/default/nginx_tile_ssl.conf.erb

index 4711428a20343525b703bd2b1c01fb9ba74915dd..37d10295fdbbe57cfc857caf90a78f51f4165193 100644 (file)
@@ -17,6 +17,8 @@
 # limitations under the License.
 #
 
+require "ipaddr"
+
 certificate = node[:tilecache][:ssl][:certificate]
 node.default[:ssl][:certificates] = node[:ssl][:certificates] | [ certificate ]
 
@@ -77,9 +79,13 @@ nginx_site "default" do
   action [ :delete ]
 end
 
+resolvers = node[:networking][:nameservers].map do |resolver|
+  IPAddr.new(resolver).ipv6? ? "[#{resolver}]" : "#{resolver}"
+end
+
 nginx_site "tile-ssl" do
   template "nginx_tile_ssl.conf.erb"
-  variables :certificate => certificate
+  variables :certificate => certificate, :resolvers => resolvers
 end
 
 service "nginx-certificate-restart" do
index 7ada68069709de077427824161d4103c9fd7af50..60059837b6cf56f5efd923fb6d8a955ee107cfc7 100644 (file)
@@ -13,8 +13,7 @@ server {
     ssl_session_cache shared:SSL:30m;
     ssl_session_timeout 15m;
     ssl_stapling on;
-    resolver <%= node[:networking][:nameservers].join(" ") %>;
+    resolver <%= @resolvers.join(" ") %>;
 
     location / { proxy_pass http://127.0.0.1; proxy_set_header X-Forwarded-For $remote_addr; }
-
 }