How to Install Squid Proxy Server on Ubuntu 18.04 LTS

Install Squid Proxy Server on Ubuntu 18

Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. Squid proxy is used by various organisation and internet providers to reduce bandwidth and to increase response time.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Squid Proxy Server on an Ubuntu 18.04 (Bionic Beaver) server.

Install Squid Proxy Server on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.


sudo apt-get update
sudo apt-get upgrade

Step 2. Installing Squid Proxy on Ubuntu 18.04 LTS.

Squid proxy package is available from the Ubuntu repositories. It can be installed by running the command:

sudo apt install squid

Step 3. Configure Squid Proxy.

First, you’ll need to do a basic configuration before you can use the Squid Proxy server:

nano /etc/squid/squid.conf
# Recommended minimum configuration:

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
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 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 SSL_ports port 9001           # webmin
acl CONNECT method CONNECT

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all
http_port 3128

forwarded_for off

request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
visible_hostname wpcademy.com

Step 4. Create our authentication file which Squid can use to verify for user authentications:

#htpasswd -b /etc/squid/squid_passwd username password

Example:

htpasswd -b -c /etc/squid/squid_passwd intan ramona

After making changes to the config file, save the file and restart the squid server service to effect the changes using the following command entered at a terminal prompt:

sudo systemctl restart squid

Congratulation’s! You have successfully installed Squid. Thanks for using this tutorial for installing Squid Proxy Server on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official Squid website.

How To Install HAProxy on Ubuntu 18.04 LTS

Install HAProxy on Ubuntu 18

HAProxy is a free HTTP/TCP high availability load balancer and proxy server. It spreads requests among multiple servers to mitigate issues resulting from single server failure. HA Proxy is used by a number of high-profile websites including GitHub, Bitbucket, Stack Overflow, Reddit, Tumblr, Twitter and Tuenti and is used in the OpsWorks product from Amazon Web Services.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation HAProxy on an Ubuntu 18.04 bionic beaver.

Install HAProxy on Ubuntu 18.04 LTS Bionic Beaver

Step 1. First, make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Network Details.

To install and configure HAProxy load balancer on Ubuntu 18.04 we will consider three system as follows:
Web Server Details:

Server 1: web1.wpcademy.com 192.168.1.104
Server 2: web1.wpcademy.com  192.168.1.105
HAProxy Server:
HAProxy: haproxy 192.168.1.46

Step 3. Installing HAProxy on Ubuntu.

At first we will install HAProxy by executing below commands:

sudo add-apt-repository ppa:vbernat/haproxy-1.7
sudo apt update
sudo apt install haproxy

Step 4. Configuring HAProxy.

Now edit haproxy default configuration file /etc/haproxy/haproxy.cfg and start configuration:

nano /etc/haproxy/haproxy.cfg

At the end of the file we will add folowing information:

<em>frontend Local_Server
bind 192.168.1.46:80
mode http
default_backend webserver</em>

backend webserver
mode http
balance roundrobin
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
option httpchk HEAD / HTTP/1.1rnHost:localhost
server system1.osradar.com 192.168.1.104:80
server system2.osradar.com 192.168.1.105:80

To verify the configuration:

sudo haproxy -c -f /etc/haproxy/haproxy.cfg

If above command return output as “configuration file is valid” then restart HAProxy service:

systemctl restart haproxy

Step 5. Accessing HAProxy.

With the HAProxy configured and running, open your load balancer server’s public IP in a web browser and check that you get connected to your backend correctly. The parameter stats uri in the configuration enables the statistics page at the defined address:

http://192.168.0.46

Congratulation’s! You have successfully installed HAProxy. Thanks for using this tutorial for installing HAProxy load balancer in Ubuntu 18.04 bionic beaver system. For additional help or useful information, we recommend you to check the official HAProxy website.