From 8db44bf97905bb100d69123d3e1c205bc8ea3661 Mon Sep 17 00:00:00 2001 From: carlba Date: Fri, 8 Feb 2019 14:32:32 +0100 Subject: [PATCH] Websocket support enabled for reverse proxy locations. (#97) * Websocket support for reverse proxy locations. --- README.md | 1 + defaults/main.yml | 1 + templates/http/default.conf.j2 | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 4c60638..616a0e9 100644 --- a/README.md +++ b/README.md @@ -350,6 +350,7 @@ nginx_http_template: backend: location: / proxy_pass: http://backend + websocket: false health_check_plus: false upstreams: upstream1: diff --git a/defaults/main.yml b/defaults/main.yml index 1fb4f04..26afd1e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -181,6 +181,7 @@ nginx_http_template: backend: location: / proxy_pass: http://backend + websocket: false health_check_plus: false upstreams: upstream1: diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 9aa80c6..e6de25c 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -41,6 +41,10 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; +{% if item.value.reverse_proxy.locations[location].websocket is defined and item.value.reverse_proxy.locations[location].websocket %} + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; +{% endif %} } {% endfor %}