From d2a6f4b81e698b8cc1ffc91e55ce0e74e4a572b8 Mon Sep 17 00:00:00 2001 From: Marcin Mielnicki Date: Thu, 7 Mar 2019 21:34:22 +0100 Subject: [PATCH] Allow to set proxy_connect_timeout and proxy_read_timeout per reverse proxy --- README.md | 2 ++ defaults/main.yml | 2 ++ templates/http/default.conf.j2 | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 782fca6..3eee770 100644 --- a/README.md +++ b/README.md @@ -365,7 +365,9 @@ nginx_http_template: locations: backend: location: / + proxy_connect_timeout: 300 proxy_pass: http://backend + proxy_read_timeout: 300 proxy_ssl: cert: /etc/ssl/certs/proxy_default.crt key: /etc/ssl/private/proxy_default.key diff --git a/defaults/main.yml b/defaults/main.yml index 919e29f..60f5b1b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -207,7 +207,9 @@ nginx_http_template: locations: backend: location: / + proxy_connect_timeout: null proxy_pass: http://backend + proxy_read_timeout: null proxy_ssl: cert: /etc/ssl/certs/proxy_default.crt key: /etc/ssl/private/proxy_default.key diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 8c3c9c0..45a9cb2 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -85,8 +85,14 @@ server { {% endif %} {% if item.value.reverse_proxy.locations[location].auth_basic_file is defined and item.value.reverse_proxy.locations[location].auth_basic_file %} auth_basic_user_file {{ item.value.reverse_proxy.locations[location].auth_basic_file }}; +{% endif %} +{% if item.value.reverse_proxy.locations[location].proxy_connect_timeout is defined and item.value.reverse_proxy.locations[location].proxy_connect_timeout %} + proxy_connect_timeout {{ item.value.reverse_proxy.locations[location].proxy_connect_timeout }}; {% endif %} proxy_pass {{ item.value.reverse_proxy.locations[location].proxy_pass }}; +{% if item.value.reverse_proxy.locations[location].proxy_read_timeout is defined and item.value.reverse_proxy.locations[location].proxy_read_timeout %} + proxy_read_timeout {{ item.value.reverse_proxy.locations[location].proxy_read_timeout }}; +{% endif %} {% if item.value.reverse_proxy.locations[location].proxy_ssl is defined %} {% if item.value.reverse_proxy.locations[location].proxy_ssl.cert is defined %}