4
status-set maintenance "Getting dstdomain" || true
5
SITENAMES="$(config-get sitenames)"
6
PORT="$(config-get port)"
7
IP="$(unit-get private-address)"
10
# Create a "localnet" rule for all addresses that can use this proxy.
11
for app in $(relation-ids forwardproxy); do
12
for unit in $(relation-list -r $app); do
13
addr="$(relation-get -r $app private-address $unit)"
14
if [[ "$addr" != "" ]]; then
15
LOCALNET="$LOCALNET\nacl localnet src $addr"
19
LOCALNET="$(echo -e $LOCALNET)"
20
# Create the squid conf that is included in the default conf.
21
cat > /etc/squid/forwardproxy.conf << EOF
24
http_access allow localnet
27
service squid restart || service squid start
29
if [[ -z $SITENAMES ]]; then
30
status-set active "Proxying: *" || true
32
status-set active "Proxying: $SITENAMES" || true
35
# Update the proxy-ees with the necessary config.
36
if [[ $0 != 'config-changed' ]]; then
37
for relation_id in $(relation-ids forwardproxy); do
38
relation-set -r $relation_id ip="$IP" port="$PORT"