From 874ffb75e6f78a6c5c4a2c866f6d937201c4f3de Mon Sep 17 00:00:00 2001 From: "Niels van der Veer (n9iels)" Date: Fri, 5 Jun 2020 14:35:33 +0200 Subject: [PATCH] Prevent nginx from crashing if IPv8 is not running --- clerk-frontend/nginx/nginx.conf | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/clerk-frontend/nginx/nginx.conf b/clerk-frontend/nginx/nginx.conf index bdb4658..902a015 100644 --- a/clerk-frontend/nginx/nginx.conf +++ b/clerk-frontend/nginx/nginx.conf @@ -2,7 +2,6 @@ events { worker_connections 1024; } - http { map $http_upgrade $connection_upgrade { default upgrade; @@ -26,16 +25,24 @@ http { ssl_certificate /etc/nginx/certs/org.crt; ssl_certificate_key /etc/nginx/certs/org.key; - location /api/ipv8/site/ { - proxy_pass http://ipv8:14410/; + # IP address of the Docker DNS resolver. Required for the '$ipv8_upstream' variables + resolver 127.0.0.11; + + location ~ ^/api/ipv8/site/?(.*) { + # The usage of a variables prevents nginx from crashing when the upstream is not found, + # This is the case when IPv8 attestation is disabled + set $ipv8_upstream http://ipv8:14410/$1$is_args$args; + proxy_pass $ipv8_upstream; } - location /api/ipv8/service/ { - proxy_pass http://ipv8:14411/; + location ~ ^/api/ipv8/service/?(.*) { + set $ipv8_upstream http://ipv8:14411/$1$is_args$args; + proxy_pass $ipv8_upstream; } - location /api/ipv8/app/ { - proxy_pass http://ipv8:14412/; + location ~ ^/api/ipv8/app/?(.*) { + set $ipv8_upstream http://ipv8:14412/$1$is_args$args; + proxy_pass $ipv8_upstream; } location /api/eph/ { @@ -48,6 +55,7 @@ http { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } + location / { root /usr/share/nginx/html; include /etc/nginx/mime.types;