|
13 | 13 | AUTO_GEN="${CONTAINER} ${AUTO_GEN}" |
14 | 14 | else |
15 | 15 | INSPECTION=$(docker inspect ${CONTAINER}) |
16 | | - for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive; do |
| 16 | + for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_preset_conf; do |
17 | 17 | VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]") |
18 | 18 | if [ "${VAR_VALUE}" == "null" ]; then |
19 | 19 | VAR_VALUE="" |
|
40 | 40 | for CONTAINER in ${AUTO_GEN}; do |
41 | 41 | INSPECTION=$(docker inspect ${CONTAINER}) |
42 | 42 | rm -rf "/auto-proxy/${CONTAINER}.conf" |
43 | | - for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive; do |
| 43 | + for VAR in swag_address swag_port swag_proto swag_url swag_auth swag_auth_bypass swag_server_custom_directive swag_preset_conf; do |
44 | 44 | VAR_VALUE=$(echo ${INSPECTION} | jq -r ".[0].Config.Labels[\"${VAR}\"]") |
45 | 45 | if [ "${VAR_VALUE}" == "null" ]; then |
46 | 46 | VAR_VALUE="" |
47 | 47 | fi |
48 | 48 | echo "${VAR}=\"${VAR_VALUE}\"" >> "/auto-proxy/${CONTAINER}.conf" |
49 | 49 | done |
50 | 50 | . /auto-proxy/${CONTAINER}.conf |
51 | | - if [ -f "/config/nginx/proxy-confs/${CONTAINER}.subdomain.conf.sample" ]; then |
52 | | - cp "/config/nginx/proxy-confs/${CONTAINER}.subdomain.conf.sample" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf" |
53 | | - echo "**** Using preset proxy conf for ${CONTAINER} ****" |
| 51 | + if [ -f "/config/nginx/proxy-confs/${CONTAINER}.subdomain.conf.sample" ] || [ -f "/config/nginx/proxy-confs/${swag_preset_conf}.subdomain.conf.sample" ]; then |
| 52 | + if [ -f "/config/nginx/proxy-confs/${CONTAINER}.subdomain.conf.sample" ]; then |
| 53 | + echo "**** Container name matches a preset proxy conf, using ${CONTAINER}.subdomain.conf for container ${CONTAINER} ****" |
| 54 | + cp "/config/nginx/proxy-confs/${CONTAINER}.subdomain.conf.sample" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf" |
| 55 | + elif [ -f "/config/nginx/proxy-confs/${swag_preset_conf}.subdomain.conf.sample" ]; then |
| 56 | + echo "**** Label swag_preset_conf matches a preset proxy conf, using ${swag_preset_conf}.subdomain.conf for container ${CONTAINER} ****" |
| 57 | + cp "/config/nginx/proxy-confs/${swag_preset_conf}.subdomain.conf.sample" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf" |
| 58 | + fi |
54 | 59 | if [ -n "${swag_auth_bypass}" ]; then |
55 | 60 | echo "**** Swag auth bypass is auto managed via preset confs and cannot be overridden via env vars ****" |
56 | 61 | fi |
@@ -96,6 +101,9 @@ for CONTAINER in ${AUTO_GEN}; do |
96 | 101 | echo "**** Enabling basic http auth for ${CONTAINER} ****" |
97 | 102 | fi |
98 | 103 | else |
| 104 | + if [ -n "${swag_preset_conf}" ] && [ ! "/config/nginx/proxy-confs/${swag_preset_conf}.subdomain.conf.sample" ]; then |
| 105 | + echo "**** Label swag_preset_conf is set, but no preset proxy conf found with the name ${swag_preset_conf}.subdomain.conf.sample ****" |
| 106 | + fi |
99 | 107 | echo "**** No preset proxy conf found for ${CONTAINER}, generating from scratch ****" |
100 | 108 | cp "/config/nginx/proxy-confs/_template.subdomain.conf.sample" "/etc/nginx/http.d/auto-proxy-${CONTAINER}.subdomain.conf" |
101 | 109 | if [ -n "${swag_auth_bypass}" ]; then |
|
0 commit comments