From 8ac755e1d661ba382da9cb6864e7eac1026080bf Mon Sep 17 00:00:00 2001 From: NaiXiaoXin Date: Sat, 24 Jun 2017 13:51:02 +0800 Subject: [PATCH 1/3] support fastcgi --- README.md | 10 ++++++++++ nginx.tmpl | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/README.md b/README.md index df3e838..aecf4e5 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,16 @@ If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the backend container. Your backend container should then listen on a port rather than a socket and expose that port. +### FastCGI Backends + +If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on the +backend container. Your backend container should then listen on a port rather +than a socket and expose that port. + +### FastCGI Filr Root Directory + +If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory + ### Default Host To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example diff --git a/nginx.tmpl b/nginx.tmpl index f23e627..57e04a7 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -146,6 +146,10 @@ upstream {{ $upstream_name }} { {{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}} {{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }} +{{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}} +{{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }} + + {{/* Get the first cert name defined by containers w/ the same vhost */}} {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }} @@ -212,6 +216,10 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi.conf; + fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} @@ -250,6 +258,10 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi.conf; + fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} From 29fffd6de80b76239aa2024ff685da22a508612d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=90=E5=B0=8F=E5=BF=83?= Date: Sat, 24 Jun 2017 14:05:42 +0800 Subject: [PATCH 2/3] Revert "support fastcgi" This reverts commit 8ac755e1d661ba382da9cb6864e7eac1026080bf. --- README.md | 10 ---------- nginx.tmpl | 12 ------------ 2 files changed, 22 deletions(-) diff --git a/README.md b/README.md index aecf4e5..df3e838 100644 --- a/README.md +++ b/README.md @@ -108,16 +108,6 @@ If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the backend container. Your backend container should then listen on a port rather than a socket and expose that port. -### FastCGI Backends - -If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on the -backend container. Your backend container should then listen on a port rather -than a socket and expose that port. - -### FastCGI Filr Root Directory - -If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory - ### Default Host To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example diff --git a/nginx.tmpl b/nginx.tmpl index 57e04a7..f23e627 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -146,10 +146,6 @@ upstream {{ $upstream_name }} { {{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}} {{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }} -{{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}} -{{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }} - - {{/* Get the first cert name defined by containers w/ the same vhost */}} {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }} @@ -216,10 +212,6 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; - {{ else if eq $proto "fastcgi" }} - root {{ trim $vhost_root }}; - include fastcgi.conf; - fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} @@ -258,10 +250,6 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; - {{ else if eq $proto "fastcgi" }} - root {{ trim $vhost_root }}; - include fastcgi.conf; - fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} From 2eb2ae9c93c46ebb7031a2a71beef2bf18da89b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=90=E5=B0=8F=E5=BF=83?= Date: Sat, 24 Jun 2017 14:48:05 +0800 Subject: [PATCH 3/3] support fastcgi --- README.md | 11 +++++++++++ nginx.tmpl | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df3e838..1cf11cb 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,17 @@ If you would like to connect to uWSGI backend, set `VIRTUAL_PROTO=uwsgi` on the backend container. Your backend container should then listen on a port rather than a socket and expose that port. +### FastCGI Backends + +If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on the +backend container. Your backend container should then listen on a port rather +than a socket and expose that port. + +### FastCGI Filr Root Directory + +If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory + + ### Default Host To set the default host for nginx use the env var `DEFAULT_HOST=foo.bar.com` for example diff --git a/nginx.tmpl b/nginx.tmpl index f23e627..1b3ff86 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -146,6 +146,10 @@ upstream {{ $upstream_name }} { {{/* Get the HTTPS_METHOD defined by containers w/ the same vhost, falling back to "redirect" */}} {{ $https_method := or (first (groupByKeys $containers "Env.HTTPS_METHOD")) "redirect" }} +{{/* Get the VIRTUAL_ROOT By containers w/ use fastcgi root */}} +{{ $vhost_root := or (first (groupByKeys $containers "Env.VIRTUAL_ROOT")) "/var/www/public" }} + + {{/* Get the first cert name defined by containers w/ the same vhost */}} {{ $certName := (first (groupByKeys $containers "Env.CERT_NAME")) }} @@ -212,6 +216,10 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi.conf; + fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} @@ -250,6 +258,10 @@ server { {{ if eq $proto "uwsgi" }} include uwsgi_params; uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "fastcgi" }} + root {{ trim $vhost_root }}; + include fastcgi.conf; + fastcgi_pass {{ trim $upstream_name }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} @@ -281,4 +293,4 @@ server { {{ end }} {{ end }} -{{ end }} +{{ end }} \ No newline at end of file