Skip to content

Commit e047e3d

Browse files
committed
Clearer naming for auto proxy related ENVs
Prefix insert/tld ENVs with AUTO_PROXY to make it clear they are related to this mod
1 parent 84c0229 commit e047e3d

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ DOCKER_HOST=192.168.0.100:2375|serverA,192.168.0.110:2375|serverB|local.test,192
6161
When using a remote docker host from `DOCKER_HOST` auto-proxy assumes the detected containers are not on the same network as SWAG:
6262
6363
* If the detected containers do not have the `swag_address` label set then the Host IP will be used.
64-
* If the detected containers do not have the `swag_port` label set then auto-proxy attempts to find a mapped **host port** on the container and will use it based on **container port** in this order:
64+
* If the detected containers do not have the `swag_port` label set then auto-proxy looks for exposed **container ports** and uses the corresponding **host port** as the upstream port. Container ports are checked in this order:
6565
* 80
6666
* 8080
6767
* The first mapped port, if any
@@ -70,29 +70,29 @@ When using a remote docker host from `DOCKER_HOST` auto-proxy assumes the detect
7070
7171
If a detected container does not have the `swag_url` label set then the subdomain and TLD can be programmatically generated.
7272
73-
The default TLD used in nginx [`server_name` directive](https://nginx.org/en/docs/http/server_names.html) can be set using `HOST_TLD`. This can also be set per-host using the syntax described in [`DOCKER_HOST` for `default_tld`.](#multiple-hosts)
73+
The default TLD used in nginx [`server_name` directive](https://nginx.org/en/docs/http/server_names.html) can be set using `AUTO_PROXY_HOST_TLD`. This can also be set per-host using the syntax described in [`DOCKER_HOST` for `default_tld`.](#multiple-hosts)
7474
75-
The subdomain used for a container can optionally be modified to include the Host's `friendly_name` described in the `DOCKER_HOST` syntax by setting `HOST_INSERT` to either `prefix` or `suffix`
75+
The subdomain used for a container can optionally be modified to include the Host's `friendly_name` described in the `DOCKER_HOST` syntax by setting `AUTO_PROXY_HOST_INSERT` to either `prefix` or `suffix`
7676
7777
Examples using a container named `overseer`:
7878
79-
* Using only HOST_INSERT to modify subdomain
79+
* Using only AUTO_PROXY_HOST_INSERT to modify subdomain
8080
* `DOCKER_HOST=192.168.0.100:2375|serverA`
81-
* `HOST_TLD` (not set, defaults to `*`)
82-
* `HOST_INSERT`
81+
* `AUTO_PROXY_HOST_TLD` (not set, defaults to `*`)
82+
* `AUTO_PROXY_HOST_INSERT`
8383
* (unset) => nginx `server_name overseer.*`
8484
* `prefix` => nginx `server_name serverA-overseer.*`
8585
* `suffix` => nginx `server_name overseer-serverA.*`
86-
* Using HOST_INSERT prefix and HOST_TLD
86+
* Using AUTO_PROXY_HOST_INSERT prefix and AUTO_PROXY_HOST_TLD
8787
* `DOCKER_HOST=192.168.0.100:2375|serverA`
88-
* `HOST_TLD=test.home`
89-
* `HOST_INSERT=prefix`
88+
* `AUTO_PROXY_HOST_TLD=test.home`
89+
* `AUTO_PROXY_HOST_INSERT=prefix`
9090
* `server_name serverA-overseer.test.home`
91-
* Using HOST_INSERT prefix and default_tld
91+
* Using AUTO_PROXY_HOST_INSERT prefix and default_tld
9292
* `DOCKER_HOST=192.168.0.100:2375|serverA|myserver.home`
93-
* `HOST_INSERT=prefix`
93+
* `AUTO_PROXY_HOST_INSERT=prefix`
9494
* `server_name serverA-overseer.myserver.home`
95-
* Using HOST_TLD only
95+
* Using AUTO_PROXY_HOST_TLD only
9696
* `DOCKER_HOST=192.168.0.100:2375`
97-
* `HOST_TLD=myserver.home`
97+
* `AUTO_PROXY_HOST_TLD=myserver.home`
9898
* `server_name overseer.myserver.home`

root/app/auto-proxy.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ DUDE
138138
else
139139
echo "**** No exposed ports found for ${CONTAINER_ID}. Setting reverse proxy port to 80. ****"
140140
swag_port="80"
141-
swag_address="${UPSTREAM_HOST}"
142141
fi
143142
else
144143
swag_port=$(docker inspect ${CONTAINER} | jq -r '.[0].NetworkSettings.Ports | keys[0]' | sed 's|/.*||')
@@ -156,12 +155,12 @@ DUDE
156155
sed -i "s|set \$upstream_proto .*|set \$upstream_proto ${swag_proto};|g" "/etc/nginx/http.d/auto-proxy-${CONTAINER_ID}.subdomain.conf"
157156
echo "**** Setting proto ${swag_proto} for ${CONTAINER_ID} ****"
158157
if [ -z "${swag_url}" ]; then
159-
if [ "$HOST_INSERT" == "suffix" ]; then
160-
swag_url="${CONTAINER}-${DOCKER_HOST_NAME}.${HOST_TLD}"
161-
elif [ "$HOST_INSERT" == "prefix" ]; then
162-
swag_url="${DOCKER_HOST_NAME}-${CONTAINER}.${HOST_TLD}"
158+
if [ "$AUTO_PROXY_HOST_INSERT" == "suffix" ]; then
159+
swag_url="${CONTAINER}-${DOCKER_HOST_NAME}.${AUTO_PROXY_HOST_TLD}"
160+
elif [ "$AUTO_PROXY_HOST_INSERT" == "prefix" ]; then
161+
swag_url="${DOCKER_HOST_NAME}-${CONTAINER}.${AUTO_PROXY_HOST_TLD}"
163162
else
164-
swag_url="${CONTAINER}.${HOST_TLD}"
163+
swag_url="${CONTAINER}.${AUTO_PROXY_HOST_TLD}"
165164
fi
166165
fi
167166
sed -i "s|server_name .*|server_name ${swag_url};|" "/etc/nginx/http.d/auto-proxy-${CONTAINER_ID}.subdomain.conf"

root/app/docker-wrap.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/with-contenv bash
22

3-
HOST_TLD_ORIG=${HOST_TLD:=*}
3+
HOST_TLD_ORIG=${AUTO_PROXY_HOST_TLD:=*}
44
if [[ -v FIRST_RUN ]];then
55
echo '**** Auto Proxy - first-run ****'
66
fi
@@ -20,17 +20,17 @@ if [[ -v DOCKER_HOST ]];then
2020
fi
2121

2222
if [[ -v arrIN[2] ]];then
23-
HOST_TLD=${arrIN[2]}
23+
AUTO_PROXY_HOST_TLD=${arrIN[2]}
2424
else
25-
HOST_TLD=$HOST_TLD_ORIG
25+
AUTO_PROXY_HOST_TLD=$HOST_TLD_ORIG
2626
fi
2727

2828
# get default upstream ip
2929
HOST_PARTS=(${DOCKER_HOST//:/ })
3030
UPSTREAM_HOST="${HOST_PARTS[0]}"
3131

3232
if [[ -v FIRST_RUN ]];then
33-
echo "**** Auto Proxy - Generating proxies for => Host: ${DOCKER_HOST} | Name: ${DOCKER_HOST_NAME:-N/A} | Default Upstream IP: ${UPSTREAM_HOST} | Host TLD: ${HOST_TLD} ****"
33+
echo "**** Auto Proxy - Generating proxies for => Host: ${DOCKER_HOST} | Name: ${DOCKER_HOST_NAME:-N/A} | Default Upstream IP: ${UPSTREAM_HOST} | Host TLD: ${AUTO_PROXY_HOST_TLD} ****"
3434
fi
3535
. /app/auto-proxy.sh
3636

@@ -40,7 +40,7 @@ fi
4040

4141
if [ -S /var/run/docker.sock ]; then
4242
if [[ -v FIRST_RUN ]];then
43-
echo "**** Auto Proxy - Detected docker.sock, generating proxies for => Host: Local | Name: Local | Default Upstream IP: N/A | Host TLD: ${HOST_TLD} ****"
43+
echo "**** Auto Proxy - Detected docker.sock, generating proxies for => Host: Local | Name: Local | Default Upstream IP: N/A | Host TLD: ${AUTO_PROXY_HOST_TLD} ****"
4444
fi
4545
DOCKER_HOST_NAME="local"
4646
unset DOCKER_HOST

0 commit comments

Comments
 (0)