mirror of
https://github.com/linuxserver/docker-mods.git
synced 2026-03-23 00:05:28 +08:00
add support for swag_location_custom_directive
This commit is contained in:
parent
5163bc88e4
commit
d4613b9086
@ -17,6 +17,7 @@ This mod gives SWAG the ability to auto-detect running containers via labels and
|
||||
- `swag_auth=authelia` - *optional* - enables auth methods (options are `authelia`, `authentik`, `ldap`, `tinyauth` and `http` for basic http auth)
|
||||
- `swag_auth_bypass=/api,/othersubfolder` - *optional* - bypasses auth for selected subfolders. Comma separated, no spaces.
|
||||
- `swag_server_custom_directive=custom_directive;` - *optional* - injects the label value as is into the server block of the generated conf. Must be a valid nginx directive, ending with a semi colon.
|
||||
- `swag_location_custom_directive=custom_directive;` - *optional* - injects the label value as is into each location block of the generated conf. Must be a valid nginx directive, ending with a semi colon.
|
||||
- `swag_preset_conf=confname` - *optional* - allows defining a preset conf to use if the container name does not match one (if the conf name is `radarr.subdomain.conf.sample`, set this value to `radarr`). If the container name matches an existing conf, this var will be ignored.
|
||||
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ else
|
||||
AUTO_GEN="${CONTAINER} ${AUTO_GEN}"
|
||||
else
|
||||
INSPECTION=$(docker inspect ${CONTAINER})
|
||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_preset_conf; do
|
||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_location_custom_directive swag_preset_conf; do
|
||||
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
||||
if [ "${VAR_VALUE}" == "null" ]; then
|
||||
VAR_VALUE=""
|
||||
@ -40,7 +40,7 @@ fi
|
||||
for CONTAINER in ${AUTO_GEN}; do
|
||||
INSPECTION=$(docker inspect ${CONTAINER})
|
||||
rm -rf "/auto-proxy/${CONTAINER}.conf"
|
||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_preset_conf; do
|
||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_location_custom_directive swag_preset_conf; do
|
||||
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
||||
if [ "${VAR_VALUE}" == "null" ]; then
|
||||
VAR_VALUE=""
|
||||
@ -87,6 +87,11 @@ for CONTAINER in ${AUTO_GEN}; do
|
||||
sed -i -e '/include.*ssl.conf;/a\' -e " ${SED_swag_server_custom_directive}" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Adding custom directive from the swag_server_custom_directive label for ${CONTAINER} ****"
|
||||
fi
|
||||
if [ -n "${swag_location_custom_directive}" ]; then
|
||||
SED_swag_location_custom_directive=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_location_custom_directive}")
|
||||
sed -i -e '/^[[:space:]]*proxy_pass.*;/a\' -e " ${SED_swag_location_custom_directive}" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Adding custom directive from the swag_location_custom_directive label for ${CONTAINER} ****"
|
||||
fi
|
||||
if [ "${swag_auth}" == "authelia" ]; then
|
||||
sed -i "s|#include /config/nginx/authelia|include /config/nginx/authelia|g" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Enabling Authelia for ${CONTAINER} ****"
|
||||
@ -164,6 +169,11 @@ DUDE
|
||||
sed -i -e '/include.*ssl.conf;/a\' -e " ${SED_swag_server_custom_directive}" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Adding custom directive from the swag_server_custom_directive label for ${CONTAINER} ****"
|
||||
fi
|
||||
if [ -n "${swag_location_custom_directive}" ]; then
|
||||
SED_swag_location_custom_directive=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_location_custom_directive}")
|
||||
sed -i -e '/^[[:space:]]*proxy_pass.*;/a\' -e " ${SED_swag_location_custom_directive}" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Adding custom directive from the swag_location_custom_directive label for ${CONTAINER} ****"
|
||||
fi
|
||||
if [ "${swag_auth}" == "authelia" ]; then
|
||||
sed -i "s|#include /config/nginx/authelia|include /config/nginx/authelia|g" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||
echo "**** Enabling Authelia for ${CONTAINER} ****"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user