added nginx variable option

GilbN 2019-12-16 12:01:45 +01:00
parent b3e7c01150
commit 512317017f

@ -5,6 +5,7 @@
<li><a href="#subfilter-method">Subfilter Method</a>
<ul>
<li><a href="#nginx">Nginx</a></li>
<li><a href="#nginx-variable">Nginx Variable</a></li>
<li><a href="#apache-untested">Apache</a></li>
</ul>
</li>
@ -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
'</head>'
'<link rel="stylesheet" type="text/css" href="https://gilbn.github.io/theme.park/CSS/themes/sonarr/plex.css">
</head>';
sub_filter_once on;
proxy_set_header Accept-Encoding "";
sub_filter
'</head>'
'<link rel="stylesheet" type="text/css" href="https://gilbn.github.io/theme.park/CSS/themes/sonarr/plex.css">
</head>';
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 <theme>;
}
```
Change `<theme>` 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
'</head>'
'<link rel="stylesheet" type="text/css" href="https://gilbn.github.io/theme.park/CSS/themes/$app/$theme.css">
</head>';
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