Monday, June 10, 2019

[Squid] Setup Linux Proxy Server and Client

The following steps are about installing and setup Linux proxy server (Squid) 

#install squid proxy
$ sudo apt-get install squid

#modify squid.conf
$ sudo vi /etc/squid/squid.conf
  ==> #add your local network segment
  acl mynetwork src 192.168.0.0/24
  ==> #allow "mynetwork" be accessing via http
  http_access allow mynetwork

#restart squid...OK
$ sudo service squid restart


And setup proxy for the client to access the proxy server:

#modify /etc/profile
$ sudo vi /etc/profile
  ==>#add these
  MY_PROXY_URL="http://10.201.0.46:3128/"

  HTTP_PROXY=$MY_PROXY_URL
  HTTPS_PROXY=$MY_PROXY_URL
  FTP_PROXY=$MY_PROXY_URL
  http_proxy=$MY_PROXY_URL
  https_proxy=$MY_PROXY_URL
  ftp_proxy=$MY_PROXY_URL
  export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy

$ source /etc/profile
# for apt
$ vi /etc/apt/apt.conf
  ==>#add these
  Acquire::http::proxy "http://10.201.0.46:3128/";
  Acquire::https::proxy "https://10.201.0.46:3128/";
  Acquire::ftp::proxy "ftp://10.201.0.46:3128/";
#for wget
$ vi /etc/wgetrc
  ==>#add these
  http_proxy = http://10.201.0.46:3128/
  https_proxy = http://10.201.0.46:3128/
  ftp_proxy = http://10.201.0.46:3128/



To find the service name which is used:

service --status-all

Other commands are:

systemctl start service - Use it to start a service. Does not persist after reboot
systemctl stop service - Use it to stop a service. Does not persist after reboot
systemctl restart service - Use it to restart a service
systemctl status service - Shows the status of a service. Tells whether a service is currently running.
systemctl enable service - Turns the service on, on the next reboot or on the next start event. It persists after reboot.
systemctl disable service - Turns the service off on the next reboot or on the next stop event. It persists after reboot.

No comments: