Skip to content

Commit

Permalink
Make nginx 'proxy_read_timeout' and 'proxy_send_timeout' configurable
Browse files Browse the repository at this point in the history
for Unicorn web apps.
  • Loading branch information
Thomas Kaschwig committed Feb 20, 2014
1 parent 6c7b9df commit 7090b96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nginx/attributes/nginx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@
default[:nginx][:worker_connections] = 1024
default[:nginx][:server_names_hash_bucket_size] = 64

default[:nginx][:proxy_read_timeout] = 60
default[:nginx][:proxy_send_timeout] = 60

include_attribute "nginx::customize"
10 changes: 10 additions & 0 deletions nginx/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@
attribute "nginx/server_names_hash_bucket_size",
:display_name => "Nginx Server Names Hash Bucket Size",
:default => "64"

attribute "nginx/proxy_read_timeout",
:display_name => "Nginx Proxy Read Timeout",
:description => "Sets the read timeout for the response of the proxied server. It determines how long nginx will wait to get the response to a request.",
:default => "60"

attribute "nginx/proxy_send_timeout",
:display_name => "Nginx Proxy Send Timeout",
:description => "Assigns timeout with the transfer of request to the upstream server.",
:default => "60"
14 changes: 14 additions & 0 deletions unicorn/templates/default/nginx_unicorn_web_app.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ server {
proxy_set_header Host $http_host;
proxy_redirect off;

<% if node[:nginx] && node[:nginx][:proxy_read_timeout] -%>
proxy_read_timeout <%= node[:nginx][:proxy_read_timeout] %>;
<% end -%>
<% if node[:nginx] && node[:nginx][:proxy_send_timeout] -%>
proxy_send_timeout <%= node[:nginx][:proxy_send_timeout] %>;
<% end -%>

# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
Expand Down Expand Up @@ -68,6 +75,13 @@ server {
proxy_set_header Host $http_host;
proxy_redirect off;

<% if node[:nginx] && node[:nginx][:proxy_read_timeout] -%>
proxy_read_timeout <%= node[:nginx][:proxy_read_timeout] %>;
<% end -%>
<% if node[:nginx] && node[:nginx][:proxy_send_timeout] -%>
proxy_send_timeout <%= node[:nginx][:proxy_send_timeout] %>;
<% end -%>

# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
Expand Down

0 comments on commit 7090b96

Please sign in to comment.