One of the tools that can help achieve efficient and secure data transfer is a proxy server. A proxy server acts as an intermediary between the user and the web, enhancing security, improving performance, and allowing for content control and caching.
Squid is one of the most popular proxy servers for linux environments. It is is a caching proxy server that supports HTTP, HTTPS, FTP, and more. It significantly improves the performance by caching repeated requests, reducing bandwidth, and improving response times.
This tutorial will guide you through the process of installing and configuring the Squid proxy server on Fedora 16.
Step 1: Install Squid Proxy Server
The first step is to install the Squid proxy server on your Fedora 16 system. This can be done using the yum command as follows:
[root@fedora16 ~]# yum install squid -y
This command will install the Squid proxy server and all its dependencies.
Examples:
[root@fedora16 ~]# yum install squid -y Fedora16-Repository | 3.7 kB 00:00 ... Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package squid.i686 7:3.2.0.16-1.fc16 will be installed --> Processing Dependency: libecap.so.2 for package: 7:squid-3.2.0.16-1.fc16.i686 --> Running transaction check ---> Package libecap.i686 0:0.2.0-2.fc16 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: squid i686 7:3.2.0.16-1.fc16 updates 2.3 M Installing for dependencies: libecap i686 0.2.0-2.fc16 updates 18 k Transaction Summary ==================================================================================================== Install 2 Packages Total download size: 2.3 M Installed size: 7.7 M Downloading Packages: (1/2): libecap-0.2.0-2.fc16.i686.rpm | 18 kB 00:00 (2/2): squid-3.2.0.16-1.fc16.i686.rpm | 2.3 MB 00:27 ---------------------------------------------------------------------------------------------------- Total 81 kB/s | 2.3 MB 00:28 Running Transaction Check Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libecap-0.2.0-2.fc16.i686 1/2 Installing : 7:squid-3.2.0.16-1.fc16.i686 2/2 Installed: squid.i686 7:3.2.0.16-1.fc16 Dependency Installed: libecap.i686 0:0.2.0-2.fc16 Complete!
Step 2: Configure Server Hosts File
Next, you need to configure the server hosts file. This can be done using the vi editor as follows:
[root@fedora16 ~]# vi /etc/hosts
In the hosts file, you should have entries similar to the following:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.47 fedora16.geeks.local
Step 3: Configure Main Squid Configuration File
The next step is to configure the main Squid configuration file. This can be done using the vi editor as follows:
[root@fedora16 ~]# vi /etc/squid/squid.conf
In the configuration file, you need to add your internal network name into the IP networks list where browsing should be allowed. For example, if your internal network name is geeks, you would add the following entry:
acl geeks src 192.168.1.0/24 # geeks network
You also need to add geeks to the http_access allow section as follows:
http_access allow geeks
Examples:
# Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network 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 geeks src 192.168.1.0/24 # geeks network
# 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
Add geeks to http_access allow as below :
# 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 geeks
Finally, make sure the Squid proxy port is uncommented. The default Squid port is 3128, but you can change it to any available port. For example, you can change it to 8080 as follows:
http_port 8080
Step 4: Configure Auto Start at Boot for Squid Service
To ensure that the Squid service starts automatically at boot, you can use the chkconfig command as follows:
[root@fedora16 ~]# chkconfig squid on
Step 5: Start and Stop Squid Service
To start the Squid service, use the following command:
[root@fedora16 ~]# service squid restart
To stop the Squid service, use the following command:
[root@fedora16 ~]# service squid stop
Step 6: Configure Firewall
Next, you need to add the Squid port to bypass the iptables firewall. Alternatively, you can disable the iptables, but it is recommended to implement iptables on the server. To stop the iptables service, use the following commands:
[root@fedora16 ~]# service iptables stop [root@fedora16 ~]# service ip6tables stop
Step 7: Configure Client Browser
Finally, you need to configure the client browser to use the Squid proxy server. The specific steps for this will depend on the browser you are using.
Full Squid 3 Configuration:
# # Recommended minimum configuration: # # Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network 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 geeks src 192.168.1.0/24 # geeks network 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 # # Recommended minimum Access Permission configuration: # # Only allow cachemgr access from localhost http_access allow localhost manager 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 # 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 # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # 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 geeks # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/spool/squid 100 16 256 # 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
Conclusion
In this tutorial, we have walked through the steps of installing and configuring the Squid proxy server on Fedora 16. By following these steps, you can set up a secure and efficient proxy server that can improve your network’s performance and security.
Remember, Squid is just one of the many proxy servers available. To choose the best one for your needs, you might want to compare different proxy servers. Check out this link for a comparison of the best proxy servers.
If you’re interested in learning more about different types of web servers, such as Apache, Nginx, LiteSpeed, and more, or if you want to understand more about different hosting options like dedicated server hosting, VPS hosting, cloud hosting, and shared hosting, visit the following links:
Feel free to leave a comment if you have any questions or need further clarification on any of the steps.