From 3e62a9247fdfffb6f914f345a361b7ad1880fe93 Mon Sep 17 00:00:00 2001 From: thismatters Date: Thu, 17 Sep 2020 07:16:53 -0500 Subject: [PATCH] Addresses #1020 by providing another means to identify the `CurrentContainer` --- README.md | 18 ++++++++++-------- nginx.tmpl | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4c680ad..7a47ddb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ See [Automated Nginx Reverse Proxy for Docker][2] for why you might want to use To run it: - $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy + $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro -e NGINX_PROXY_CONTAINER=true jwilder/nginx-proxy Then start any containers you want proxied with an env var `VIRTUAL_HOST=subdomain.youdomain.com` @@ -48,6 +48,8 @@ services: - "80:80" volumes: - /var/run/docker.sock:/tmp/docker.sock:ro + environment: + - NGINX_PROXY_CONTAINER=true whoami: image: jwilder/whoami @@ -128,11 +130,11 @@ 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 File Root Directory If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory @@ -292,11 +294,11 @@ site after changing this setting, your browser has probably cached the HSTS poli redirecting you back to HTTPS. You will need to clear your browser's HSTS cache or use an incognito window / different browser. -By default, [HTTP Strict Transport Security (HSTS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) -is enabled with `max-age=31536000` for HTTPS sites. You can disable HSTS with the environment variable -`HSTS=off` or use a custom HSTS configuration like `HSTS=max-age=31536000; includeSubDomains; preload`. -*WARNING*: HSTS will force your users to visit the HTTPS version of your site for the `max-age` time - -even if they type in `http://` manually. The only way to get to an HTTP site after receiving an HSTS +By default, [HTTP Strict Transport Security (HSTS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) +is enabled with `max-age=31536000` for HTTPS sites. You can disable HSTS with the environment variable +`HSTS=off` or use a custom HSTS configuration like `HSTS=max-age=31536000; includeSubDomains; preload`. +*WARNING*: HSTS will force your users to visit the HTTPS version of your site for the `max-age` time - +even if they type in `http://` manually. The only way to get to an HTTP site after receiving an HSTS response is to clear your browser's HSTS cache. ### Basic Authentication Support diff --git a/nginx.tmpl b/nginx.tmpl index 07e2b50..57cb58e 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -1,4 +1,4 @@ -{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }} +{{ $CurrentContainer := or (where $ "ID" .Docker.CurrentContainerID | first) (where $ "Env.NGINX_PROXY_CONTAINER" "true" | first) }} {{ $external_http_port := coalesce $.Env.HTTP_PORT "80" }} {{ $external_https_port := coalesce $.Env.HTTPS_PORT "443" }}