mirror of
https://github.com/TrezOne/docker-mods-uptime-kuma-timeout-fix.git
synced 2026-07-19 01:46:10 -04:00
Merge pull request #778 from linuxserver/swag-auto-proxy-custom
Add support for new `swag_server_custom_directive` label
This commit is contained in:
@@ -16,6 +16,7 @@ This mod gives SWAG the ability to auto-detect running containers via labels and
|
|||||||
- `swag_url=containername.domain.com` - *optional* - overrides *server_name* (defaults to `containername.*`)
|
- `swag_url=containername.domain.com` - *optional* - overrides *server_name* (defaults to `containername.*`)
|
||||||
- `swag_auth=authelia` - *optional* - enables auth methods (options are `authelia`, `authentik`, `ldap` and `http` for basic http auth)
|
- `swag_auth=authelia` - *optional* - enables auth methods (options are `authelia`, `authentik`, `ldap` and `http` for basic http auth)
|
||||||
- `swag_auth_bypass=/api,/othersubfolder` - *optional* - bypasses auth for selected subfolders. Comma separated, no spaces.
|
- `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.
|
||||||
|
|
||||||
|
|
||||||
In SWAG docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-auto-proxy` and either add a volume mapping for `/var/run/docker.sock:/var/run/docker.sock:ro`, or set an environment var `DOCKER_HOST=remoteaddress`.
|
In SWAG docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:universal-docker|linuxserver/mods:swag-auto-proxy` and either add a volume mapping for `/var/run/docker.sock:/var/run/docker.sock:ro`, or set an environment var `DOCKER_HOST=remoteaddress`.
|
||||||
|
|||||||
+16
-4
@@ -13,7 +13,7 @@ else
|
|||||||
AUTO_GEN="${CONTAINER} ${AUTO_GEN}"
|
AUTO_GEN="${CONTAINER} ${AUTO_GEN}"
|
||||||
else
|
else
|
||||||
INSPECTION=$(docker inspect ${CONTAINER})
|
INSPECTION=$(docker inspect ${CONTAINER})
|
||||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass; do
|
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive; do
|
||||||
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
||||||
if [ "${VAR_VALUE}" == "null" ]; then
|
if [ "${VAR_VALUE}" == "null" ]; then
|
||||||
VAR_VALUE=""
|
VAR_VALUE=""
|
||||||
@@ -40,7 +40,7 @@ fi
|
|||||||
for CONTAINER in ${AUTO_GEN}; do
|
for CONTAINER in ${AUTO_GEN}; do
|
||||||
INSPECTION=$(docker inspect ${CONTAINER})
|
INSPECTION=$(docker inspect ${CONTAINER})
|
||||||
rm -rf "/auto-proxy/${CONTAINER}.conf"
|
rm -rf "/auto-proxy/${CONTAINER}.conf"
|
||||||
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass; do
|
for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive; do
|
||||||
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]")
|
||||||
if [ "${VAR_VALUE}" == "null" ]; then
|
if [ "${VAR_VALUE}" == "null" ]; then
|
||||||
VAR_VALUE=""
|
VAR_VALUE=""
|
||||||
@@ -67,9 +67,15 @@ for CONTAINER in ${AUTO_GEN}; do
|
|||||||
echo "**** Overriding proto as ${swag_proto} for ${CONTAINER} ****"
|
echo "**** Overriding proto as ${swag_proto} for ${CONTAINER} ****"
|
||||||
fi
|
fi
|
||||||
if [ -n "${swag_url}" ]; then
|
if [ -n "${swag_url}" ]; then
|
||||||
sed -i "s|server_name .*|server_name ${swag_url};|" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
SED_swag_url=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_url}")
|
||||||
|
sed -i "s|server_name .*|server_name ${SED_swag_url};|" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||||
echo "**** Overriding url as ${swag_url} for ${CONTAINER} ****"
|
echo "**** Overriding url as ${swag_url} for ${CONTAINER} ****"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "${swag_server_custom_directive}" ]; then
|
||||||
|
SED_swag_server_custom_directive=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_server_custom_directive}")
|
||||||
|
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 [ "${swag_auth}" == "authelia" ]; then
|
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"
|
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} ****"
|
echo "**** Enabling Authelia for ${CONTAINER} ****"
|
||||||
@@ -133,8 +139,14 @@ DUDE
|
|||||||
if [ -z "${swag_url}" ]; then
|
if [ -z "${swag_url}" ]; then
|
||||||
swag_url="${CONTAINER}.*"
|
swag_url="${CONTAINER}.*"
|
||||||
fi
|
fi
|
||||||
sed -i "s|server_name .*|server_name ${swag_url};|" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
SED_swag_url=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_url}")
|
||||||
|
sed -i "s|server_name .*|server_name ${SED_swag_url};|" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf"
|
||||||
echo "**** Setting url ${swag_url} for ${CONTAINER} ****"
|
echo "**** Setting url ${swag_url} for ${CONTAINER} ****"
|
||||||
|
if [ -n "${swag_server_custom_directive}" ]; then
|
||||||
|
SED_swag_server_custom_directive=$(sed -e 's/[&\\|]/\\&/g; s|$|\\|; $s|\\$||' <<<"${swag_server_custom_directive}")
|
||||||
|
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 [ "${swag_auth}" == "authelia" ]; then
|
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"
|
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} ****"
|
echo "**** Enabling Authelia for ${CONTAINER} ****"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
sed -i '/\/app\/auto-proxy.sh/d' /config/crontabs/root
|
sed -i '/\/app\/auto-proxy.sh/d' /etc/crontabs/root
|
||||||
rm -rf /etc/nginx/http.d/auto-proxy*.conf /config/nginx/proxy-confs/auto-proxy*.conf
|
rm -rf /etc/nginx/http.d/auto-proxy*.conf /config/nginx/proxy-confs/auto-proxy*.conf
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ cp /defaults/auto-proxy-readme /etc/nginx/http.d/auto-proxy-readme
|
|||||||
rm -rf /auto-proxy
|
rm -rf /auto-proxy
|
||||||
mkdir /auto-proxy
|
mkdir /auto-proxy
|
||||||
|
|
||||||
if ! grep -q "/app/auto-proxy.sh" /config/crontabs/root; then
|
if ! grep -q "/app/auto-proxy.sh" /etc/crontabs/root; then
|
||||||
echo "* * * * * /app/auto-proxy.sh" >> /config/crontabs/root
|
echo "* * * * * /app/auto-proxy.sh" >> /etc/crontabs/root
|
||||||
cp /config/crontabs/root /etc/crontabs/root
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/app/auto-proxy.sh
|
/app/auto-proxy.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user