Created
October 7, 2020 19:47
-
-
Save vitalvas/ee500f5bf9cf0115577e38a7fed06cc8 to your computer and use it in GitHub Desktop.
squid docker auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Author: <[email protected]> Vitaliy Vasilenko | |
| # run: usermod -a -G docker proxy | |
| # tested on squid 4.10 | |
| while read line; do | |
| ip_addr=$(echo "${line}" | awk '{print $1}') | |
| ip_done="0" | |
| for ctx in $(docker ps | awk '$NF!="NAMES" {print $NF}'); do | |
| for addr in $(docker inspect ${ctx} | jq -r '.[].NetworkSettings.Networks[].IPAddress'); do | |
| if [ "${ip_addr}" == "${addr}" ]; then | |
| echo "OK user=docker:${ctx}" | |
| ip_done="1" | |
| fi | |
| done | |
| done | |
| if [ "${ip_done}" == "0" ]; then | |
| echo "ERR" | |
| fi | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| external_acl_type docker_ips ttl=60 negative_ttl=20 children-max=1 grace=90 %SRC /etc/squid/auth_docker.sh | |
| acl DockerAuthIPs external docker_ips | |
| http_access allow DockerAuthIPs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment