From cdb0b7d2f1af35b277e7b2d01d3ff8253997136d Mon Sep 17 00:00:00 2001
From: "nicolas.dorier" <nicolas.dorier@gmail.com>
Date: Wed, 23 Jan 2019 00:13:52 +0900
Subject: [PATCH] Make sure routes for nginx are only generated for btcpay
 service

---
 Production/nginx.tmpl                                         | 4 ++++
 .../docker-fragments/btcpayserver-nginx.yml                   | 1 +
 2 files changed, 5 insertions(+)

diff --git a/Production/nginx.tmpl b/Production/nginx.tmpl
index 1c99182..5e67e91 100644
--- a/Production/nginx.tmpl
+++ b/Production/nginx.tmpl
@@ -160,6 +160,8 @@ upstream {{ $upstream_name }} {
 {{/* Get the VIRTUAL_PROTO defined by containers w/ the same vhost, falling back to "http" */}}
 {{ $proto := trim (or (first (groupByKeys $containers "Env.VIRTUAL_PROTO")) "http") }}
 
+{{ $service_name := trim (or (first (groupByKeys $containers "Env.VIRTUAL_SERVICE_NAME")) "") }}
+
 {{/* Get the NETWORK_ACCESS defined by containers w/ the same vhost, falling back to "external" */}}
 {{ $network_tag := or (first (groupByKeys $containers "Env.NETWORK_ACCESS")) "external" }}
 
@@ -297,6 +299,7 @@ server {
 		{{ end }}
 	} 
 
+	{{ if eq $service_name "btcpay" }}
 	{{ range $container := $ }}
 		{{ $serviceName := (index $container.Labels "com.docker.compose.service") }}
 		{{ if (eq $serviceName "lnd_bitcoin") }}
@@ -339,6 +342,7 @@ server {
 		{{ end }}
 		
 		
+	{{ end }}
 	{{ end }}
 }
 
diff --git a/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml
index 366353a..9a65d4a 100644
--- a/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml
+++ b/docker-compose-generator/docker-fragments/btcpayserver-nginx.yml
@@ -8,6 +8,7 @@ services:
       VIRTUAL_NETWORK: nginx-proxy
       VIRTUAL_PORT: 49392
       VIRTUAL_HOST: ${BTCPAY_HOST}
+      VIRTUAL_SERVICE_NAME: "btcpay"
       SSL_POLICY: Mozilla-Modern 
 
       # Let's encrypt settings