Squid 3.5 forward proxy on CentOS
I've been looking into providing a good proxy server to replace the old stalwart Threat Management Gateway which is now out of support and development from Microsoft.
Having recently passed my Redhat exam I thought I would look for something a bit LINUX based to run the proxy. This led me to find SQUID.
http://www.squid-cache.org
There is plenty of documentation around how to set up the proxy.
Typically with LINUX, the documentation is written assuming that the reader knows what is going on
and is not a beginner.
I got the basic proxy up and running pretty quickly. I even had WPAD working correctly!
The defaults all worked!
However the sticking point was how to get Squid to use an Active Directory group to determine who has
access to the Internet.
Here's how I implemented the whole thing. From start to finish. As much as I can remember.
Obviously I'll omit the days of effort pursuing failures and just present the successes so it looks like I know
what I am talking about rather than the hunt and peck style used in reality :)
Oh and as I am a RedHat certified engineer I used CentOS 6 (running on VMPlayer).
Having recently passed my Redhat exam I thought I would look for something a bit LINUX based to run the proxy. This led me to find SQUID.
http://www.squid-cache.org
There is plenty of documentation around how to set up the proxy.
Typically with LINUX, the documentation is written assuming that the reader knows what is going on
and is not a beginner.
I got the basic proxy up and running pretty quickly. I even had WPAD working correctly!
The defaults all worked!
However the sticking point was how to get Squid to use an Active Directory group to determine who has
access to the Internet.
Here's how I implemented the whole thing. From start to finish. As much as I can remember.
Obviously I'll omit the days of effort pursuing failures and just present the successes so it looks like I know
what I am talking about rather than the hunt and peck style used in reality :)
Oh and as I am a RedHat certified engineer I used CentOS 6 (running on VMPlayer).
- AD Config
- Create a group to control internet access
- CENTOS Config
- Using yum install httpd, ntp, squid, samba, samba-common, winbind, gcc, kerberos (server and client) and msktutil
- IP ADDRESS : 10.20.30.40
- HOSTNAME : squid
- DOMAIN : contoso.com
- NTP Config
- [root@squid ~]# vi /etc/ntp.conf
- [root@squid ~]# service ntpd start
- [root@squid ~]# chkconfig ntpd on
- APACHE Config
- [root@squid ~]# service httpd start
- [root@squid ~]# chkconfig httpd on
- [root@squid ~]# vi /var/www/http/wpad.dat
- SAMBA Config
- [root@squid ~]# vi /etc/samba/smb.conf
- KERBEROS Config
- [root@squid ~]# vi /etc/krb5.conf
- [root@squid ~]# vi /var/kerberos/krb5kdc/kdc.conf
- Check you progress!
- [root@squid ~]# kinit admin@CONTOSO.COM
- The next command takes a while to complete so be patient!
- [root@squid ~]# kdb5_util create -s
- [root@squid ~]# net ads join -U admin@CONTOSO.COM
- [root@squid ~]# service smb start
- [root@squid ~]# service winbind start
- [root@squid ~]# service krb5kdc start
- [root@squid ~]# chkconfig smb on
- [root@squid ~]# chkconfig winbind on
- [root@squid ~]# chkconfig krb5kdc on
- Check your progress!
- [root@squid ~]# wbinfo -u
- SQUID Config
- [root@squid ~]# vi /etc/squid/squid.conf
I can't figure out a nice way to embed the config files in the main text so here they are:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool http://www.pool.ntp.org/join.html).
server ntp-server.contoso.com
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
// WPAD File
function FindProxyForURL(url, host){
//If they have only specified a hostname, go directly
if (isPlainHostName(host)
return "DIRECT"
// Go direct to intranet site
if (shExpMatch( host, "intranet*"))
return "DIRECT";
//Connect directly to our domains
if (dnsDomainIs( host,"*.contoso.com"))
return "DIRECT";
// If not resolvable send direct to get correct error messages
if (!isResolvable(host))
return "DIRECT";// Only cache http, ftp and gopher
// Go direct if PROXY not available
if (url.substring(0, 5) == "http:" ||
url.substring(0,6) == "https:" ||
url.substring(0, 4) == "ftp:" ||
url.substring(0, 7) == "gopher:")
return "PROXY 10.20.30.40:3128; DIRECT";
// In all other cases go direct
else
return "DIRECT";
}
ntp.conf - edit the lines shown:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool http://www.pool.ntp.org/join.html).
server ntp-server.contoso.com
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
wpad.dat
// WPAD File
function FindProxyForURL(url, host){
//If they have only specified a hostname, go directly
if (isPlainHostName(host)
return "DIRECT"
// Go direct to intranet site
if (shExpMatch( host, "intranet*"))
return "DIRECT";
//Connect directly to our domains
if (dnsDomainIs( host,"*.contoso.com"))
return "DIRECT";
// If not resolvable send direct to get correct error messages
if (!isResolvable(host))
return "DIRECT";// Only cache http, ftp and gopher
// Go direct if PROXY not available
if (url.substring(0, 5) == "http:" ||
url.substring(0,6) == "https:" ||
url.substring(0, 4) == "ftp:" ||
url.substring(0, 7) == "gopher:")
return "PROXY 10.20.30.40:3128; DIRECT";
// In all other cases go direct
else
return "DIRECT";
}
smb.conf
workgroup = CONTOSO
security = ads
realm = CONTOSO.COM
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind use default domain = yes
winbind enum users = yes
winbind enum groups = yes
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = CONTOSO.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
CONTOSO.COM = {
kdc = ad-server.contoso.com:88
admin_server = ad-server.contoso.com:749
}
[domain_realm]
.contoso.com = CONTOSO.COM
contoso.com = CONTOSO.COM
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
CONTOSO.COM = {
#master_key_type = aes256-cts
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
}
squid.conf - I am using a 64bit version of CentOS so needed to use lib64 not lib
security = ads
realm = CONTOSO.COM
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind use default domain = yes
winbind enum users = yes
winbind enum groups = yes
krb5.conf
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = CONTOSO.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
CONTOSO.COM = {
kdc = ad-server.contoso.com:88
admin_server = ad-server.contoso.com:749
}
[domain_realm]
.contoso.com = CONTOSO.COM
contoso.com = CONTOSO.COM
kdc.conf
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
CONTOSO.COM = {
#master_key_type = aes256-cts
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
}
squid.conf - I am using a 64bit version of CentOS so needed to use lib64 not lib
squid.conf - I am now using CentOS 7 and squid 3 so I need the line:external_acl_type nt_group ttl=0 children=5 %LOGIN /usr/lib64/squid/ext_wbinfo_group_acl
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param ntlm children 30
auth_param ntlm keep_alive on
auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
external_acl_type nt_group ttl=0 children=5 %LOGIN /usr/lib64/squid/wbinfo_group.pl -d
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
visible_hostname squid.contoso.com
acl AuthUsers external nt_group CONTOSO\Group_AllUsers
http_access allow AuthUsers all
http_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256 coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param ntlm children 30
auth_param ntlm keep_alive on
auth_param basic program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
external_acl_type nt_group ttl=0 children=5 %LOGIN /usr/lib64/squid/wbinfo_group.pl -d
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
visible_hostname squid.contoso.com
acl AuthUsers external nt_group CONTOSO\Group_AllUsers
http_access allow AuthUsers all
http_access deny all
http_port 3128
hierarchy_stoplist cgi-bin ?
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256 coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
This comment has been removed by the author.
ReplyDelete