From 512317017fcecc148b7997f29801f01e748faee2 Mon Sep 17 00:00:00 2001 From: GilbN Date: Mon, 16 Dec 2019 12:01:45 +0100 Subject: [PATCH] added nginx variable option --- Setup.md | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/Setup.md b/Setup.md index b54a437..b1a858b 100644 --- a/Setup.md +++ b/Setup.md @@ -5,6 +5,7 @@
  • Subfilter Method
  • @@ -51,15 +52,79 @@ Where `APP_NAME` is the app you want to theme and `THEME.css` is the name of the location /sonarr { proxy_pass http://localhost:8989/sonarr; include /config/nginx/proxy.conf; - proxy_set_header Accept-Encoding ""; - sub_filter - '' - ' - '; - sub_filter_once on; + proxy_set_header Accept-Encoding ""; + sub_filter + '' + ' + '; + sub_filter_once on; } ``` +### Nginx Variable + +You can also setup Nginx to use variables to change the themes. This will update the theme on all your location blocks by just changing 1 variable. This is nice if you quickly want to change colors on all of your apps. + +#### http block + +In you http block add the following: + +```nginx +# THEME.PARK +map $host $theme { + default ; +} +``` +Change `` to the theme you want on all your apps. e.g. `default dark;` + +Available themes are: + `aquamarine` + `hotline` + `plex` + `dark` + `space-gray` + +#### theme-park.conf +Next create a new file called `theme-park.conf` and add the following code: (Note: It's not really necessary to create the conf file but I think it looks cleaner in the location blocks) + +```nginx + proxy_set_header Accept-Encoding ""; + sub_filter + '' + ' + '; + sub_filter_once on; +``` +As you can see the URL has variables in it `/$app/$theme.css` +The `$theme` variable is set in the http block and will affect all server blocks. And the `$app` variable is set in the location block. + +#### location blocks + +Now in the location block use the include syntax and include the theme-park.conf file and set the $app variable, like so: + +```nginx + set $app sonarr; + include /config/nginx/theme-park.conf; +``` + +**Example** +```nginx +location /sonarr { + proxy_pass http://192.168.1.34:8990/sonarr; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_redirect off; + proxy_buffering off; + proxy_http_version 1.1; + proxy_no_cache $cookie_session; + set $app sonarr; + include /config/nginx/theme-park.conf; + } +``` + +Now when you change the variable in the http block and restart nginx, it will update the theme for all your apps! + ### Apache (Untested) ```apache AddOutputFilterByType SUBSTITUTE text/html