Skip to content

Commit d957adf

Browse files
committed
allow basic auth configuration for squid
1 parent 5f2f931 commit d957adf

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

ansible/roles/squid/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,15 @@ Where noted these map to squid parameters of the same name without the `squid_`
2020
- `squid_maximum_object_size_in_memory`: Optional str. Upper size limit for objects in memory cache, default '64 MB'. See squid parameter.
2121
- `squid_maximum_object_size`: Optional str. Upper size limit for objects in disk cache, default '200 MB'. See squid parameter.
2222
- `squid_http_port`: Optional str. Socket addresses to listen for client requests, default '3128'. See squid parameter.
23-
- `squid_acls`: Optional str, can be multiline. Define access lists. Default `acl anywhere src all`, i.e. rely on OpenStack security groups (or other firewall if deployed). See squid parameter `acl`. NB: The default template also defines acls for `SSL_ports` and `Safe_ports` as is common practice.
24-
- `squid_http_access`: Optional str, can be multiline. Allow/deny access based on access lists. Default:
23+
- `squid_acls`: Optional list of strs. Define access lists. Default: `['acl anywhere src all']`, i.e. allow connection from anywhere, relying on OpenStack security groups (or other firewall if deployed). See squid parameter `acl`. NB: The default template also defines acls for `SSL_ports` and `Safe_ports` as is common practice.
24+
- `squid_http_access`: Optional str, can be multiline. Allow/deny access based on access lists. The default will:
25+
- Deny requests to certain unsafe ports (see `squid.conf.j2`)
26+
- Deny CONNECT to other than secure SSL ports
27+
- Only allow cachemgr access from localhost
28+
- Allow access for all ACLs defined in `squid_acls`
29+
- Allow access for localhost
30+
- Deny all other access
2531

26-
# Deny requests to certain unsafe ports
27-
http_access deny !Safe_ports
28-
# Deny CONNECT to other than secure SSL ports
29-
http_access deny CONNECT !SSL_ports
30-
# Only allow cachemgr access from localhost
31-
http_access allow localhost manager
32-
http_access deny manager
33-
# Rules allowing http access
34-
http_access allow anywhere
35-
http_access allow localhost
36-
# Finally deny all other access to this proxy
37-
http_access deny all
38-
3932
See squid parameter.
33+
34+
- `squid_auth_param`: Optional str, can be multiline. Parameters for authentication schemes. Default empty string.

ansible/roles/squid/defaults/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ squid_cache_disk: "{{ undef(hint='squid_cache_disk (in MB) required, e.g. \"1024
88
squid_maximum_object_size_in_memory: '64 MB'
99
squid_maximum_object_size: '200 MB'
1010
squid_http_port: 3128
11-
squid_acls: acl anywhere src all # rely on openstack security groups
11+
squid_acls:
12+
- acl anywhere src all # rely on openstack security groups
1213
squid_http_access: |
1314
# Deny requests to certain unsafe ports
1415
http_access deny !Safe_ports
@@ -18,7 +19,10 @@ squid_http_access: |
1819
http_access allow localhost manager
1920
http_access deny manager
2021
# Rules allowing http access
21-
http_access allow anywhere
22+
{% for acl in squid_acls %}
23+
http_access allow {{ (acl | split)[1] }}
24+
{% endfor %}
2225
http_access allow localhost
2326
# Finally deny all other access to this proxy
2427
http_access deny all
28+
squid_auth_param: ''

ansible/roles/squid/templates/squid.conf.j2

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
# - https://github.com/drosskopp/squid-cache/blob/main/squid.conf
55
#
66

7+
# Configure authentication parameters
8+
# NB: required before ACL definitions using them
9+
{{ squid_auth_param }}
10+
711
# Define ACLs:
8-
{{ squid_acls }}
12+
{% for acl in squid_acls %}
13+
{{ acl }}
14+
{% endfor %}
915

1016
acl SSL_ports port 443
1117
acl Safe_ports port 80 # http

0 commit comments

Comments
 (0)