Squid proxy server is a UNIx-based proxy server that can provide HTTP proxy. Squid is deployed on a machine with a public network and an Intranet IP address, and then the Squid is provided to the Intranet machine for proxy service, so that the Intranet machine can also access external websites

You can also use other methods of HTTP proxy, such as Java implementation of HTTP proxy server, etc., see my other document: Java implementation of HTTP proxy server & Through HTTP proxy for Intranet installation of yum software

1. Install

yum install -y squid
Copy the code

2. Set password authentication

If the authentication account is admin and the password is admin123, run the following command and enter the password. Htpasswd -c /etc/squid/passwd admin ## create a new account htpasswd /etc/squid/passwd user2 ## Create a new account htpasswd /etc/squid/passwd user2 # yum install -y HTTPD # yum install -y HTTPDCopy the code

3. Set squid.conf

  1. ## annotate all http_access allow references first

  1. ## Add the following configuration above the http_access deny all line
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm chao's squid server
auth_param basic credentialsttl 2 hours
acl myacl proxy_auth REQUIRED
http_access allow myacl
http_access deny all
Copy the code

3. ## Add several log-related configurations to facilitate log management

cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
logfile_rotate 3
Copy the code

4. Start the Squid service

## start systemctl start squid ## stop systemctl stop squidCopy the code

5.Squid log management

Clear crontab -e periodically every day through scheduled tasks

0 3 * * * /usr/sbin/squid -k rotate
Copy the code

6. Use it on the client

export http_proxy=http:/ / admin: [email protected]:3128
export https_proxy=http:/ / admin: [email protected]:3128
export no_proxy='127.0.0.1'
Copy the code

Run the export command and then perform normal operations, such as: