Author Topic: ubuntu20.04 setup proxy with username password authenticated.  (Read 3167 times)


  • Administrator
  • Hero Member
  • *****
  • Posts: 2143
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
ubuntu20.04 setup proxy with username password authenticated.
« on: กุมภาพันธ์ 01, 2022, 11:46:45 PM »
===install squid on ubuntu20.04
apt update
apt install squid
systemctl status squid.service
systemctl enable squid.service
vi /etc/squid/squid.conf

===start of squid.conf===
# 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
 # Only allow cachemgr access from localhost
 http_access allow localhost manager
 http_access deny manager
 # We strongly recommend the following be uncommented to protect innocent
 # web applications running on the proxy server who think the only
 # one who can access services on "localhost" is a local user
 #http_access deny to_localhost
 include /etc/squid/conf.d/*
 ##allow user pass authen via proxy
 auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwords
 auth_param basic realm proxy
 acl authenticated proxy_auth REQUIRED
 ##add from golf ip whois current ip check via
 acl localnet src
 # Example rule allowing access from your local networks.
 # Adapt localnet in the ACL section to list your (internal) IP networks
 # from where browsing should be allowed
 #http_access allow localnet
 #http_access allow localhost
 http_access allow authenticated
 # And finally deny all other access to this proxy
 http_access deny all
===end of squid.conf===

===after that last step need to install for htaccess password user
apt install apache2-utils
htpasswd -c /etc/squid/passwords axpkl2
systemctl restart squid.service
ufw allow 3128

=====setup proxy user and password
htpasswd  /etc/squid/passwords axpkl3

==test from pc or Macbook (
curl -v -x http://axpkl2:pklpkl2@

=====show log could connect via proxy normally
===tail -f /var/log/squid/access.log
1643733370.341      0 TCP_DENIED/407 4051 CONNECT axpkl HIER_NONE/- text/html
1643733378.519    291 TCP_TUNNEL/200 26450 CONNECT axpkl2 HIER_DIRECT/
« Last Edit: กุมภาพันธ์ 01, 2022, 11:58:48 PM by golfreeze »