Crmgo Blog

Configuring Squid with NCSA Authentication

Configuring Squid with NCSA Authentication

yum install squid vim /etc/squid/squid.conf Attention! In version 3.3, the line needs to be replaced with If you have x64: Create a user: if apache is not installed: yum install httpd-tools # htpasswd -c /etc/squid/internet_users admin 1234567 To add another user, use: # htpasswd…

Configuring Squid with NCSA Authentication

yum install squid

 

vim /etc/squid/squid.conf

###################

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


via off
forwarded_for off

request_header_access Server deny all
request_header_access WWW-Authenticate deny all
request_header_access Link deny all
request_header_access Cache-Control deny all
request_header_access Proxy-Connection deny all
request_header_access X-Cache deny all
request_header_access X-Cache-Lookup deny all
request_header_access Via deny all
request_header_access X-Forwarded-For deny all
request_header_access Pragma deny all
request_header_access Keep-Alive deny all

cache_access_log /dev/null
cache_store_log none
cache_log /dev/null
logfile_rotate 0


auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/internet_users
auth_param basic children 5
auth_param basic realm =lomix proxy=
auth_param basic credentialsttl 2 hours
acl internet_users proxy_auth REQUIRED
http_access allow internet_users


dns_nameservers 8.8.8.8

#aximum_object_size_in_memory 102400
#ache_dir ufs /var/spool/squid/ 4096 16 256
cache_effective_user squid
cache_effective_group squid

http_access deny all


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

# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# And finally deny all other access to this proxy
http_access deny all

# Заменить на свой IP
http_port xxx.xxx.xxx.xxx:3333


# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
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

Note! In version 3.3, the line

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/internet_users

must be replaced with

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/internet_users

If you are using x64:

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/internet_users

Create a user:

if apache is not installed:

yum install httpd-tools

# htpasswd -c /etc/squid/internet_users admin 1234567

To add another user, use:

# htpasswd -b /etc/squid/internet_users admin 1234567

After creating the file and users, do not forget to set the appropriate permissions on the /etc/squid/internet_users file.

# chmod 440 /etc/squid/internet_users
# chown squid:squid /etc/squid/internet_users

vim /etc/sysconfig/iptables

-A INPUT -p tcp -m tcp --dport 3333 -j ACCEPT

service iptables restart

service squid start

chkconfig squid on

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.