From 51c219d651de134ba352b081d60fd33d155d9cd7 Mon Sep 17 00:00:00 2001 From: pabra Date: Tue, 22 Dec 2015 21:20:44 +0100 Subject: [PATCH] connect to uWSGI backends --- README.md | 7 ++++++- nginx.tmpl | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d4bb40..7116775 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,12 @@ You can also use wildcards at the beginning and the end of host name, like `*.ba If you would like to connect to your backend using HTTPS instead of HTTP, set `VIRTUAL_PROTO=https` on the backend container. +### uWSGI Backends + +If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the +backend container. Your backend container should than listen on a port rather +than a socket and expose that port. + ### Default Host To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example @@ -227,4 +233,3 @@ Before submitting pull requests or issues, please check github to make sure an e To run tests, you'll need to install [bats 0.4.0](https://github.com/sstephenson/bats). make test - diff --git a/nginx.tmpl b/nginx.tmpl index 255cc35..71ccc31 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -144,7 +144,12 @@ server { {{ end }} location / { + {{ if eq $proto "uwsgi" }} + include uwsgi_params; + uwsgi_pass {{ trim $proto }}://{{ trim $host }}; + {{ else }} proxy_pass {{ trim $proto }}://{{ trim $host }}; + {{ end }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; @@ -170,7 +175,12 @@ server { {{ end }} location / { + {{ if eq $proto "uwsgi" }} + include uwsgi_params; + uwsgi_pass {{ trim $proto }}://{{ trim $host }}; + {{ else }} proxy_pass {{ trim $proto }}://{{ trim $host }}; + {{ end }} {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};