From 4fd1d46a301e03da9480a9bb111d3aa9a4e9b8a0 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 15 Nov 2021 04:01:04 +0400 Subject: [PATCH] Kek, just realised that you can actually use map directive to declare variables in http block. :) --- homepage/views/articles/nginx_recipes_and_tips.pug | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homepage/views/articles/nginx_recipes_and_tips.pug b/homepage/views/articles/nginx_recipes_and_tips.pug index d9d8ce4..e8dfbf2 100644 --- a/homepage/views/articles/nginx_recipes_and_tips.pug +++ b/homepage/views/articles/nginx_recipes_and_tips.pug @@ -55,3 +55,9 @@ block article | location /assets/ { | alias $root/homepage/static/assets/; | } + p The very reason why I had to use variables is that #[code alias] doesn't work with relative paths. I wish #[code alias] could be relative to #[code root], but we are forced to look for workarounds. + p Update: Oh, I realised that you can declare variables in #[code http] block using #[code map] directive with #[code default] set to value you need. Funny, I've been using #[code map] to prevent LAN IPs from being logged all this time, heh. So, here's example: + pre + | map 1 $root { + | default /srv/http/dwelling; + | }