From e1787074108b8f12a40ebea454ba3e81d0ffc91d Mon Sep 17 00:00:00 2001 From: Alex Banna Date: Fri, 5 Sep 2014 19:26:23 -0700 Subject: [PATCH 1/2] Adding resolver to nginx.conf --- attributes/default.rb | 22 ++++++++++++++++++++++ templates/default/nginx.conf.erb | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/attributes/default.rb b/attributes/default.rb index d4e834f..8142446 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -104,6 +104,28 @@ # multi_accept tries to accept() as many connections as possible after nginx # gets notification about a new connection. default[:nginx][:multi_accept] = "off" + +# +# Configures name servers used to resolve names of upstream servers into addresses, for example: +# resolver 127.0.0.1 [::1]:5353; +# An address can be specified as a domain name or IP address, and an optional port (1.3.1, 1.2.2). +# If port is not specified, the port 53 is used. Name servers are queried in a round-robin fashion. +# By default, nginx will look up both IPv4 and IPv6 addresses while resolving. If looking up of IPv6 addresses is not desired, +# the ipv6=off parameter can be specified. +# Resolving of names into IPv6 addresses is supported starting from version 1.5.8. +# By default, nginx caches answers using the TTL value of a response. An optional valid parameter allows overriding it: +# resolver 127.0.0.1 [::1]:5353 valid=30s; +default[:nginx][:resolver] = nil + +# Before version 1.1.9, tuning of caching time was not possible, and nginx always cached answers for the duration of 5 minutes. +# Syntax: resolver_timeout time; +# Default: +# resolver_timeout 30s; +# Context: http, server, location +# Sets a timeout for name resolution, for example: +# resolver_timeout 5s; +default[:nginx][:resolver][:timeout] = '30s' + # # Directive activate or deactivate the usage of sendfile(). # sendfile() copies data between one file descriptor and another. Because this diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index baeb4f5..a7b63f2 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -20,6 +20,14 @@ http { tcp_nopush <%= node[:nginx][:tcp_nopush] %>; tcp_nodelay <%= node[:nginx][:tcp_nodelay] %>; + <%- unless node[:nginx][:resolver].nil? -%> + ## + # Resolver Settings + ## + resolver <%= node[:nginx][:resolver] %>; + resolver_timeout <%= node[:nginx][:resolver][:timeout] %>; + <%- end -%> + ## # Timeouts ## From 54c951fea53e3bb68d5c94947bdc9e42d02d2092 Mon Sep 17 00:00:00 2001 From: Alex Banna Date: Fri, 5 Sep 2014 19:29:52 -0700 Subject: [PATCH 2/2] fixed naming issue. --- attributes/default.rb | 2 +- templates/default/nginx.conf.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 8142446..88a82b6 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -124,7 +124,7 @@ # Context: http, server, location # Sets a timeout for name resolution, for example: # resolver_timeout 5s; -default[:nginx][:resolver][:timeout] = '30s' +default[:nginx][:resolver_timeout] = '30s' # # Directive activate or deactivate the usage of sendfile(). diff --git a/templates/default/nginx.conf.erb b/templates/default/nginx.conf.erb index a7b63f2..c04c452 100644 --- a/templates/default/nginx.conf.erb +++ b/templates/default/nginx.conf.erb @@ -25,7 +25,7 @@ http { # Resolver Settings ## resolver <%= node[:nginx][:resolver] %>; - resolver_timeout <%= node[:nginx][:resolver][:timeout] %>; + resolver_timeout <%= node[:nginx][:resolver_timeout] %>; <%- end -%> ##