cache docker + squid vm ou externe
This commit is contained in:
@ -1,14 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Upstream proxy
|
||||
echo "cache_peer 192.168.0.121 parent 3128 0 no-query default
|
||||
acl all src 0.0.0.0/0.0.0.0
|
||||
http_access allow all
|
||||
never_direct allow all" >> /etc/squid/squid.conf
|
||||
PROXY="192.168.0.121:3128"
|
||||
REGISTRY="192.168.0.121:5000"
|
||||
|
||||
service squid restart
|
||||
# Pour le proxy http/https (https sans cache) avec iptables
|
||||
cat >> /etc/rc.local <<EOF
|
||||
#!/bin/sh
|
||||
PROXY=${PROXY}
|
||||
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 3142 -j DNAT --to \${PROXY}
|
||||
iptables -t nat -A OUTPUT -p tcp -m tcp --dport 3142 -j DNAT --to \${PROXY}
|
||||
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
EOF
|
||||
chmod +x /etc/rc.local
|
||||
echo "net.ipv4.conf.eth0.route_localnet=1" >> /etc/sysctl.conf
|
||||
sysctl -p
|
||||
# fin proxy
|
||||
|
||||
# Pour le cache docker
|
||||
cat >> /etc/rc.local <<EOF
|
||||
REGISTRY=${REGISTRY}
|
||||
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 5000 -j DNAT --to \${REGISTRY}
|
||||
EOF
|
||||
# fin cache docker
|
||||
|
||||
|
||||
bash /etc/rc.local
|
||||
|
||||
# Un peu de customisation
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y vim rsync
|
||||
rsync -a /vagrant/files/.emacs* /root/
|
||||
|
||||
|
||||
###
|
||||
# Une autre façon de router vers un autre proxy http/https upstream, si on veut que la VM fasse le cache
|
||||
###
|
||||
# Pour le proxy http/https (https sans cache) avec squid config
|
||||
#echo "cache_peer $(cut -d':' -f1 <<< $PROXY) parent $(cut -d':' -f2 <<< $PROXY) 0 no-query default
|
||||
#acl all src 0.0.0.0/0.0.0.0
|
||||
#http_access allow all
|
||||
#never_direct allow all" >> /etc/squid/squid.conf
|
||||
#service squid restart
|
||||
|
Reference in New Issue
Block a user