{"id":205,"date":"2017-08-15T13:48:38","date_gmt":"2017-08-15T13:48:38","guid":{"rendered":"http:\/\/info.ffteixeira.net\/2017\/08\/15\/install-and-configure-squid-proxy-server-clamav-squidclamav-c-icap-server-debian-9-minimal-standard-system-utilities-ssh-server\/"},"modified":"2017-08-15T13:48:38","modified_gmt":"2017-08-15T13:48:38","slug":"install-and-configure-squid-proxy-server-clamav-squidclamav-c-icap-server-debian-9-minimal-standard-system-utilities-ssh-server","status":"publish","type":"post","link":"https:\/\/blog.ffteixeira.net\/?p=205","title":{"rendered":"Install and Configure Squid Proxy Server, ClamAV, SquidClamav, C-ICAP Server \u2013 Debian 9 (minimal &#8211; standard system utilities, ssh server)"},"content":{"rendered":"<p>1. Install some needed dependencies.<br \/><strong>$sudo apt-get install gcc make curl libcurl4-gnutls-dev rsync<\/strong><\/p>\n<p>2. Install and Configure Squid Proxy Server.<br \/><strong>$sudo apt-get install squid3 calamaris<\/strong><\/p>\n<p>3.Edit config file \/etc\/squid\/squid.conf:<br \/><strong>$sudo cp squid.conf squid.conf.ORIG<\/strong><\/p>\n<p>Backup<br \/><strong>$sudo cp \/etc\/squid\/squid.conf \/etc\/squid\/squid.conf.bak<\/strong><\/p>\n<p>To simplify the configuration file (squid.conf), we can remove everything that is comments or blank lines.<br \/><strong>$sudo cat squid.conf.bak | egrep -v -e &#039;^[[:blank:]]*#|^$&#039; &gt; squid.conf<\/strong><\/p>\n<p><strong>$sudo nano \/etc\/squid\/squid.conf<\/strong><\/p>\n<p>3.1 Change squid.conf options<\/p>\n<p>Make sure the line is uncommented (#).<br \/><em>acl CONNECT method CONNECT<\/em><\/p>\n<p>Create new access lists acl LAN to your internal network 192.168.0.0\/24. or others internal network<br \/><em>acl LAN src 192.168.0.0\/24<br \/>acl LAN src xxx.xxx.x.x\/24<\/em><\/p>\n<p>Additional access lists blacklist, whitelist, malware_block_list to block spam, commercials, malware, viruses&hellip;<\/p>\n<p><em>acl malware_block_list url_regex -i &quot;\/etc\/squid\/malware_block_list&quot;<br \/>acl blacklist dstdom_regex &quot;\/etc\/squid\/blacklist&quot;<br \/>acl whitelist dstdom_regex &quot;\/etc\/squid\/whitelist&quot;<\/em><\/p>\n<p>Access new acl lists &ndash; order matters:<\/p>\n<p><em>http_access allow whitelist<br \/>http_access deny blacklist<br \/>http_access deny malware_block_list<br \/>http_access allow LAN<\/em><\/p>\n<p><strong>I did not use:<\/strong> Inform users about blocked website. Blocked commercials will be displayed as empty transparent place, require http server.<br \/><em>deny_info http:\/\/YourServerName\/error\/dot-transparent.png blacklist<br \/>deny_info http:\/\/YourServerName\/error\/dot-transparent.png whitelist<br \/>deny_info http:\/\/YourServerName\/error\/error.html malware_block_list<\/em><\/p>\n<p>Setup address IP and listening port. Transparent mean no caching.<br \/><em>http_port 192.168.0.1:3128<\/em><\/p>\n<p>Additional&nbsp; setup &ndash; Anonymizer. Blocking headers:<br \/><em>request_header_access Allow allow all<br \/>request_header_access Authorization allow all<br \/>request_header_access WWW-Authenticate allow all<br \/>request_header_access Proxy-Authorization allow all<br \/>request_header_access Proxy-Authenticate allow all<br \/>request_header_access Content-Encoding allow all<br \/>request_header_access Content-Length allow all<br \/>request_header_access Content-Type allow all<br \/>request_header_access Date allow all<br \/>request_header_access Expires allow all<br \/>request_header_access Host allow all<br \/>request_header_access If-Modified-Since allow all<br \/>request_header_access Last-Modified allow all<br \/>request_header_access Location allow all<br \/>request_header_access Pragma allow all<br \/>request_header_access Accept allow all<br \/>request_header_access Accept-Charset allow all<br \/>request_header_access Accept-Encoding allow all<br \/>request_header_access Accept-Language allow all<br \/>request_header_access Content-Language allow all<br \/>request_header_access Mime-Version allow all<br \/>request_header_access Retry-After allow all<br \/>request_header_access Title allow all<br \/>request_header_access Connection allow all<br \/>request_header_access Proxy-Connection allow all<br \/>request_header_access User-Agent allow all<br \/>request_header_access Cookie allow all<br \/>request_header_access Referer deny all<br \/>request_header_access X-Forwarded-For deny all<br \/>request_header_access Via deny all<br \/>request_header_access All deny all<br \/>request_header_access Cache-Control deny all<br \/>httpd_suppress_version_string on<\/em><\/p>\n<p>Store cache ojects only in memory, cache (400MB)<\/p>\n<p>## <a href=\"..\/blog\/?q=content\/squid-caching-configuration\">Cache options<\/a><\/p>\n<p><em>cache_mem 512 MB<br \/>cache_dir ufs \/var\/spool\/squid3 400 16 256<\/em>&nbsp; ### cache_dir ufs \/usr\/local\/squid\/cache 51200 64 256<\/p>\n<p>Disable cache for access list &ndash; LAN:<br \/><em>cache deny LAN<\/em><\/p>\n<p>Hostname<br \/><em>visible_hostname YourServerName<\/em><\/p>\n<p>Hiding IP<br \/><em>forwarded_for off<\/em><\/p>\n<p><em>##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- My test config &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<em>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/em><\/em><br \/><em>acl LAN src 192.168.0.0\/24<br \/>acl LAN src 192.168.100.0\/24<br \/>acl LAN src 192.168.122.0\/24<\/p>\n<p>acl SSL_ports port 443<br \/>acl Safe_ports port 80&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# http<br \/>acl Safe_ports port 21&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# ftp<br \/>acl Safe_ports port 443&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# https<br \/>acl Safe_ports port 70&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# gopher<br \/>acl Safe_ports port 210&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# wais<br \/>acl Safe_ports port 1025-65535&nbsp;&nbsp; &nbsp;# unregistered ports<br \/>acl Safe_ports port 280&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# http-mgmt<br \/>acl Safe_ports port 488&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# gss-http<br \/>acl Safe_ports port 591&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# filemaker<br \/>acl Safe_ports port 777&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;# multiling http<br \/>acl CONNECT method CONNECT<\/p>\n<p>acl malware_block_list url_regex -i &quot;\/etc\/squid\/malware_block_list&quot;<br \/>acl blacklist dstdom_regex &quot;\/etc\/squid\/blacklist&quot;<br \/>acl whitelist dstdom_regex &quot;\/etc\/squid\/whitelist&quot;<br \/>http_access allow whitelist<br \/>http_access deny blacklist<br \/>http_access deny malware_block_list<\/p>\n<p>http_access deny !Safe_ports<br \/>http_access deny CONNECT !SSL_ports<br \/>http_access allow localhost manager<br \/>http_access deny manager<br \/>http_access allow LAN<br \/>http_access allow localhost<br \/>http_access deny all<\/p>\n<p>visible_hostname proxy<br \/>http_port 3128<br \/>coredump_dir \/var\/spool\/squid<\/p>\n<p>refresh_pattern ^ftp:&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;1440&nbsp;&nbsp; &nbsp;20%&nbsp;&nbsp; &nbsp;10080<br \/>refresh_pattern ^gopher:&nbsp;&nbsp; &nbsp;1440&nbsp;&nbsp; &nbsp;0%&nbsp;&nbsp; &nbsp;1440<br \/>refresh_pattern -i (\/cgi-bin\/|\\?) 0&nbsp;&nbsp; &nbsp;0%&nbsp;&nbsp; &nbsp;0<br \/>refresh_pattern .&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;0&nbsp;&nbsp; &nbsp;20%&nbsp;&nbsp; &nbsp;4320<\/p>\n<p>request_header_access Allow allow all<br \/>request_header_access Authorization allow all<br \/>request_header_access WWW-Authenticate allow all<br \/>request_header_access Proxy-Authorization allow all<br \/>request_header_access Proxy-Authenticate allow all<br \/>request_header_access Content-Encoding allow all<br \/>request_header_access Content-Length allow all<br \/>request_header_access Content-Type allow all<br \/>request_header_access Date allow all<br \/>request_header_access Expires allow all<br \/>request_header_access Host allow all<br \/>request_header_access If-Modified-Since allow all<br \/>request_header_access Last-Modified allow all<br \/>request_header_access Location allow all<br \/>request_header_access Pragma allow all<br \/>request_header_access Accept allow all<br \/>request_header_access Accept-Charset allow all<br \/>request_header_access Accept-Encoding allow all<br \/>request_header_access Accept-Language allow all<br \/>request_header_access Content-Language allow all<br \/>request_header_access Mime-Version allow all<br \/>request_header_access Retry-After allow all<br \/>request_header_access Title allow all<br \/>request_header_access Connection allow all<br \/>request_header_access Proxy-Connection allow all<br \/>request_header_access User-Agent allow all<br \/>request_header_access Cookie allow all<br \/>request_header_access Referer deny all<br \/>request_header_access X-Forwarded-For deny all<br \/>request_header_access Via deny all<br \/>request_header_access All deny all<br \/>request_header_access Cache-Control deny all<br \/>httpd_suppress_version_string on<\/em><br \/>&nbsp;<\/p>\n<p>## <a href=\"..\/blog\/?q=content\/squid-caching-configuration\">Cache options<\/a><\/p>\n<p><em><em>cache_mem 512 MB<\/em><br \/>cache_dir ufs \/var\/spool\/squid 400 16 256<br \/>cache deny LAN<br \/>visible_hostname proxy<br \/>forwarded_for off<\/p>\n<p>##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<em>&#8212;&#8212;&#8211;<em>&#8212;&#8212;&#8211;<em>&#8212;&#8212;&#8211;<\/em><\/em><\/em><\/em><\/p>\n<p>3.2 Download files: blacklist and whitelist, unpack and save it to \/etc\/squid\/.<br \/><strong>$wget -c https:\/\/ffteixeira.net\/blog\/sites\/default\/files\/blacklist.tar_.bz2 <\/strong>(rename blacklist.tar_.bz2 to blacklist.tar.bz2)<strong> || <strong>wget -c <\/strong>http:\/\/terminal28.com\/wp-content\/uploads\/2013\/10\/blacklist.tar.bz2<br \/>$sudo tar -xvf blacklist.tar.bz2<br \/>$sudo mv blacklist whitelist \/etc\/squid<\/strong><\/p>\n<p>Before trying to start Squid, you should verify that your squid.conf file makes sense. This is easy to do. Just run the following command:<br \/><strong>$sudo squid -k parse<\/strong><\/p>\n<p>Ignore this error, solved next step:<br \/><em>&#8230;\/08\/11 12:23:16| Processing: acl malware_block_list url_regex -i &quot;\/etc\/squid\/malware_block_list&quot;<br \/>&#8230;\/08\/11 12:23:16| ERROR: Can not open file \/etc\/squid\/malware_block_list for reading<br \/>&#8230;\/08\/11 12:23:16| Warning: empty ACL: acl malware_block_list url_regex -i &quot;\/etc\/squid\/malware_block_list&quot;<br \/>&#8230;\/08\/11 12:23:16| Processing: acl blacklist dstdom_regex &quot;\/etc\/squid\/blacklist&quot;<br \/>&#8230;\/08\/11 12:23:17| \/etc\/squid\/squid.conf line 20: acl blacklist dstdom_regex &quot;\/etc\/squid\/blacklist&quot;<br \/>&#8230;\/08\/11 12:23:17| WARNING: there are more than 100 regular expressions. Consider using less REs or use rules without expressions like &#039;dstdomain&#039;.<\/em><\/p>\n<p>Restart Squid.<br \/><strong>$sudo \/etc\/init.d\/squid restart<\/strong><\/p>\n<p>3.3 Download script malware_block_list to update domains and IP addresses , unpack and save it to \/etc\/squid<br \/><strong><strong>$wget -c <\/strong>https:\/\/ffteixeira.net\/blog\/sites\/default\/files\/malware_block_list.tar_.bz2 <\/strong>(rename malware_block_list.tar_.bz2&nbsp; to malware_block_list.tar.bz2)<strong> || wget -c http:\/\/terminal28.com\/wp-content\/uploads\/2013\/10\/malware_block_list.tar.bz2<\/strong><br \/><strong>$sudo tar -xvf malware_block_list.tar.bz2<br \/>$sudo mv malware_block_list \/usr\/local\/bin\/<br \/>$sudo chmod +x \/usr\/local\/bin\/malware_block_list<br \/>$sudo touch&nbsp; \/var\/log\/malware_block_list.log<\/strong><\/p>\n<p>Add script malware_block_list to Cron.<br \/><strong>$sudo crontab -e<\/strong><\/p>\n<p>add<br \/>&nbsp;&nbsp; &nbsp;<br \/><em>@daily \/usr\/local\/bin\/malware_block_list<\/em><\/p>\n<p>Logfile location: \/var\/log\/malware_block_list.log.&nbsp;&nbsp; Go to&nbsp; MalwarePatrol.net, click tab: Block List. You should see subscription list: free and paid. Click Free\/Subscribe. Subscribe the list. You should get password\/receipt number on email. Log in to: https:\/\/www.malwarepatrol.net\/login.php; and find Squid Web Proxy ACL and click Download. You will be redirected to website\/text with malware list. Every subscription has unique receipt number receipt=f1234567890. https:\/\/lists.malwarepatrol.net\/cgi\/getfile?receipt=f1234567890&amp;product=8&amp;list=squid Copy URL and paste to script near link. Edit: link, user, pass.<\/p>\n<p><strong>$sudo nano \/usr\/local\/bin\/malware_block_list<\/strong><\/p>\n<p><em>link=&#039;PASTE_LINK_FROM_MALWAREPATROL.NET&#039;<br \/>user=&#039;&#8211;http-user=USERNAME&#039;<br \/>passwd=&#039;&#8211;http-passwd=PASSWORD&#039;<\/em><\/p>\n<p><strong>Note:<\/strong> Change squid3 to squid<\/p>\n<p><em>##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- My test config. &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>#!\/bin\/sh<br \/>### ###<br \/>###<br \/>### Squid3 Installation and Configuration.<br \/>###<br \/>### Polish version<br \/>###<br \/>### http:\/\/man.sethuper.com\/instalacja-squid-proxy-serwer-clamav-squidclamav-c-icap-serwer-debian-6-0-x<br \/>###<br \/>#=======================================================================================================================<br \/>###<br \/>### English version<br \/>###<br \/>### http:\/\/terminal28.com\/how-to-install-and-configure-squid-proxy-server-clamav-squidclamav-c-icap-server-debian-linux\/<br \/>###<br \/>### ###<\/p>\n<p># If you don&#039;t want to log wget debug output remove &quot;$debug&quot; in line (51) &quot;fetchcmd&quot;<\/p>\n<p>## Setings<br \/># Malware patrol URL with unique ID<br \/># Change ID after receipt in link (..getfile?receipt=f138125701..)<br \/>link=&#039;https:\/\/lists.malwarepatrol.net\/cgi\/getfile?receipt=f1502379316&amp;product=8&amp;list=squid&#039;<\/p>\n<p># HTTP USER<br \/>user=&#039;&#8211;http-user=&lt;user&gt;&#039;<\/p>\n<p># HTTP PASSWORD<br \/>pass=&#039;&#8211;http-passwd=&lt;passwd&gt;&#039;<\/p>\n<p># Checking certificate<br \/>cert=&#039;&#8211;no-check-certificate&#039;<\/p>\n<p># File location for Squid<br \/>target=&#039;\/etc\/squid\/malware_block_list&#039;<\/p>\n<p># Reload Squid<br \/>reloadcmd=&#039;\/usr\/sbin\/squid -k reconfigure&#039;<\/p>\n<p># Temporary file<br \/>tmp=&quot;\/tmp\/.malware_block_list.$$&quot;<\/p>\n<p># Wget debud<br \/>#debug=&quot;-nva \/var\/log\/squid\/malware_block_list.log&quot;<\/p>\n<p># Command for download malware list<br \/>#I remove de debug because error<br \/>#fetchcmd=&quot;wget -q&nbsp; &#8211;no-check-certificate&nbsp; $link -O $tmp $user $pass $debug&quot;<br \/>fetchcmd=&quot;wget -q&nbsp; &#8211;no-check-certificate&nbsp; $link -O $tmp $user $pass&quot;<\/p>\n<p># &#8212;&#8212;-<\/p>\n<p># Log file<br \/>logs=&#039;\/var\/log\/squid\/malware_block_list.log&#039;<\/p>\n<p>## execution<br \/>##<br \/>echo &quot;$(date -R) Downloading new malware_block_list&quot; &gt;&gt; &quot;$logs&quot;<\/p>\n<p># Downloading new malware_block_list from Malware Patrol<br \/>$fetchcmd<\/p>\n<p># Checking temporary file &ndash; &quot;OK&quot; &ndash; before overwrite old malware list<br \/>if [ ! -s $tmp ]<br \/>then<br \/>echo &quot;$(date -R) The temporary file &#039;$tmp&#039; does not exist or is empty; resignation&quot; &gt;&gt; &quot;$logs&quot;<br \/>exit<br \/>fi<\/p>\n<p># moving malware_black_list to directory \/etc\/squid3\/<br \/>cp&nbsp; $tmp $target<\/p>\n<p># removing temporary file<br \/>rm $tmp<\/p>\n<p># restart Squid<br \/>$reloadcmd<br \/>##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/em><\/p>\n<p>&nbsp;<br \/><strong>$sudo sh \/usr\/local\/bin\/malware_block_list<\/strong><\/p>\n<p>4. Install Clamav-server.<br \/><strong>$sudo apt-get install clamav-daemon<br \/>$sudo mkdir install<br \/>$cd install<br \/>$sudo wget https:\/\/sourceforge.net\/projects\/c-icap\/files\/c-icap\/0.5.x\/c_icap-0.5.2.tar.gz\/download -O c_icap-0.5.2.tar.gz<br \/>$sudo tar -xvf c_icap-0.5.2.tar.gz<br \/>$cd c_icap-0.5.2<br \/>$sudo .\/configure<br \/>$sudo make<br \/>$sudo make install<br \/>$cd ..<\/strong><\/p>\n<p>Edit configfile&nbsp; \/usr\/local\/etc\/c-icap.conf.<br \/><strong>$sudo nano \/usr\/local\/etc\/c-icap.conf<\/strong><\/p>\n<p>Change:<\/p>\n<p><em>Line 223: ServerAdmin root@localhost<br \/>Line 232: ServerName YourServerName<\/em><\/p>\n<p>Add at line 708:<\/p>\n<p><em>Service squidclamav squidclamav.so<\/em><\/p>\n<p>4.1 C-ICAP server autostart script.<br \/><strong>$<strong>wget -c&nbsp; <\/strong>https:\/\/ffteixeira.net\/blog\/sites\/default\/files\/c-icap-autostart.tar_.gz <\/strong>(rename c-icap-autostart.tar_.gz&nbsp; to c-icap-autostart.tar.gz)<strong> || wget -c http:\/\/terminal28.com\/wp-content\/uploads\/2013\/10\/c-icap-autostart.tar.gz<br \/>$sudo tar xvf c-icap-autostart.tar.gz<br \/>$sudo rsync -avh init.d default \/etc<br \/>$sudo update-rc.d c-icap defaults<\/strong><\/p>\n<p>4.2 Create logrotate script for c-icap server.<br \/><strong>$sudo cat &lt;&lt; EOT &gt; \/etc\/logrotate.d\/c-icap<\/strong><\/p>\n<p><em>\/usr\/local\/var\/log\/server.log \/usr\/local\/var\/log\/access.log {<br \/>&nbsp;&nbsp;&nbsp;&nbsp; daily<br \/>&nbsp;&nbsp;&nbsp;&nbsp; rotate 4<br \/>&nbsp;&nbsp;&nbsp;&nbsp; missingok<br \/>&nbsp;&nbsp;&nbsp;&nbsp; notifempty<br \/>&nbsp;&nbsp;&nbsp;&nbsp; compress<br \/>&nbsp;&nbsp;&nbsp;&nbsp; create 0644 root root<br \/>&nbsp;&nbsp;&nbsp;&nbsp; postrotate<br \/>&nbsp;&nbsp;&nbsp;&nbsp; \/etc\/init.d\/c-icap force-reload &gt; \/dev\/null<br \/>&nbsp;&nbsp;&nbsp;&nbsp; endscript<br \/>}<br \/>EOT<\/em><\/p>\n<p>4.3 Change permission for c-icap logrotate script and server logs.<br \/><strong>$sudo chmod 644 \/etc\/logrotate.d\/c-icap<br \/>$sudo chown root:root \/etc\/logrotate.d\/c-icap<br \/>$sudo chmod 644 \/usr\/local\/var\/log\/ -R<br \/>$sudo chown root:root \/usr\/local\/var\/log\/ -R<br \/>$sudo ln -s \/usr\/local\/var\/log\/server.log \/var\/log\/server.log<br \/>$sudo ln -s \/usr\/local\/var\/log\/access.log \/var\/log\/access.log<\/strong><\/p>\n<p>5. Install Squidclamav<br \/><strong>$cd install<br \/>$wget -c https:\/\/sourceforge.net\/projects\/squidclamav\/files\/squidclamav\/6.15\/squidclamav-6.15.tar.gz\/download -O squidclamav-6.15.tar.gz<br \/>$sudo tar zxvf squidclamav-6.15.tar.gz<br \/>$cd squidclamav-6.15<br \/>$sudo .\/configure<br \/>$sudo make<br \/>$sudo make install<br \/>$cp -rf cgi-bin \/usr\/lib\/<br \/>$chmod +x \/usr\/lib\/cgi-bin\/clwarn* -R<br \/>$chown www-data:www-data \/usr\/lib\/cgi-bin\/clwarn* -R<br \/>$cd ..<br \/>$sudo ldconfig<\/strong><\/p>\n<p>5.1 Configure squidclamav.<br \/><strong>$sudo nano \/usr\/lcocal\/etc\/squidclamav.conf<\/strong><\/p>\n<p>Add redirect URL &ndash; default script &ndash; clwarn.cgi (en). You can choose diferent language: DE, FR, BR, RU.<\/p>\n<p><em>Line 18: redirect http:\/\/YourServerName\/cgi-bin\/clwarn.cgi<\/em><\/p>\n<p>Make sure the rule occurs in configfile.<\/p>\n<p><em>Line 27: clamd_local \/var\/run\/clamav\/clamd.ctl<\/em><\/p>\n<p>6. Checking config file &ndash; ClamAV, make sure the rule occurs in configfile.<br \/><strong>$sudo nano \/etc\/clamav\/clamd.conf<\/strong><\/p>\n<p><em>Line 4: LocalSocket \/var\/run\/clamav\/clamd.ctl<\/em><\/p>\n<p>Configure Freshclam.<br \/><strong>$sudo nano \/etc\/clamav\/freshclam.conf<\/strong><\/p>\n<p><em>Line 22: SafeBrowsing true<\/em><\/p>\n<p>6.1 Register on Securiteinfo.com: https:\/\/www.securiteinfo.com\/clients\/customers\/signup<br \/>Subscribe basic list for clamav. You should get auto generated urls for clamav database under tab: Setup.<br \/>Download allowed from 1 IP address, limited to 24 downloads per day<br \/>Add generated URLS to freshclam.conf file at the end.<\/p>\n<p><em>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/3b4d0&#8230;5764\/securiteinfo.hdb<br \/>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/3b4b&#8230;eafd\/securiteinfo.ign2<br \/>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/3b4d0d&#8230;61eafd\/javascript.ndb<br \/>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/34d&#8230;81f\/spam_marketing.ndb<br \/>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/3b&#8230;61eafd\/securiteinfohtml.hdb<br \/>DatabaseCustomURL http:\/\/www.securiteinfo.com\/get\/signatures\/3b&#8230;365afd\/securiteinfoascii.hdb<\/em><\/p>\n<p>Restart ClamAV.<br \/><strong>$sudo \/etc\/init.d\/clamav-daemon restart<\/strong><\/p>\n<p>7. Configure Squid with C-ICAP. Configuration for Squid version &ndash; 3.1.20.<br \/><strong>$sudo nano \/etc\/squid\/squid.conf<\/strong><\/p>\n<p>Add at the end of the file<\/p>\n<p><em>icap_enable on<br \/>icap_send_client_ip on<br \/>icap_send_client_username on<br \/>icap_client_username_header X-Authenticated-User<br \/>icap_service service_req reqmod_precache bypass=1 icap:\/\/127.0.0.1:1344\/squidclamav<br \/>adaptation_access service_req allow all<br \/>icap_service service_resp respmod_precache bypass=1 icap:\/\/127.0.0.1:1344\/squidclamav<br \/>adaptation_access service_resp allow all<\/em><\/p>\n<p>Configuration for Squid version &ndash; 3.1.6.<br \/><strong>$sudo nano \/etc\/squid\/squid.conf<\/strong><\/p>\n<p>Add at the end of the file<\/p>\n<p><em>icap_enable on<br \/>icap_send_client_ip on<br \/>icap_send_client_username on<br \/>icap_client_username_encode off<br \/>icap_client_username_header X-Client-Username<br \/>icap_preview_enable on<br \/>icap_preview_size 1024<br \/>adaptation_service_set service_req<br \/>icap_service service_req reqmod_precache bypass=1 icap:\/\/127.0.0.1:1344\/request<br \/>adaptation_access service_req allow all<\/p>\n<p>adaptation_service_set service_resp<br \/>icap_service service_resp respmod_precache bypass=0 icap:\/\/127.0.0.1:1344\/response<br \/>adaptation_access service_resp allow all<\/em><\/p>\n<p>Run C-ICAP server.<br \/><strong>$sudo \/usr\/local\/bin\/c-icap &amp;<\/strong><\/p>\n<p>8. Restart Squid.<br \/><strong>$sudo chown -R proxy:proxy \/var\/spool\/squid<br \/>$sudo squid -z<br \/>$sudo service squid restart<\/strong><\/p>\n<p>9. Configure firewall &ndash; masquerade, prerouting.<br \/>Enable forwarding. Edit configfile sysctl.conf<br \/><strong>$sudo nano \/etc\/sysctl.conf<\/strong><\/p>\n<p>Uncomment IPv4 i IPv6 and change to 1:<\/p>\n<p><em>Line 28: net.ipv4.ip_forward = 1<br \/>Line 33: net.ipv6.conf.all.forwarding = 1<\/em><\/p>\n<p>##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- Not used &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>9.1. Configure firewall &ndash; iptables.<\/p>\n<p>$sudo nano \/etc\/iptables.up.rules<\/p>\n<p>Add rules (Change address IP and network interface)<\/p>\n<p><em>*nat<\/p>\n<p>-A PREROUTING -p tcp -m tcp -i eth1 &#8211;dport 80 -j REDIRECT &#8211;to-ports 3128<br \/>-A POSTROUTING -s 192.168.0.0\/24 -j MASQUERADE<\/em><br \/>&nbsp;##&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>10. Test.<\/p>\n<p>If you have done it right then..<br \/>.. go to: http:\/\/www.eicar.org\/85-0-Download.html and try to download file:<\/p>\n<p>eicar.com<br \/>68 Bytes<\/p>\n<p>Result:<br \/>You should be redirected to:<\/p>\n<p>&nbsp;&nbsp;&nbsp; http:\/\/YourServerName\/cgi-bin\/clwarn.cgi, http:\/\/YourServerName\/error.html.<\/p>\n<p>11. <a href=\"..\/blog\/?q=content\/sarg-squid-analysis-report-generator-installation-configuration\">Sarg<\/a> and <a href=\"..\/blog\/?q=content\/install-squidguard-debian-9\">squidguard<\/a><\/p>\n<p><a href=\"http:\/\/terminal28.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Credits<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Install some needed dependencies.$sudo apt-get install gcc make curl libcurl4-gnutls-dev rsync 2. Install and Configure Squid Proxy Server.$sudo apt-get install squid3 calamaris 3.Edit config file \/etc\/squid\/squid.conf:$sudo cp squid.conf squid.conf.ORIG Backup$sudo cp \/etc\/squid\/squid.conf \/etc\/squid\/squid.conf.bak To simplify the configuration file (squid.conf), &hellip; <a href=\"https:\/\/blog.ffteixeira.net\/?p=205\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5,6,9,31,35,36,37],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c-icap","tag-clamav","tag-debian-9","tag-proxy","tag-server","tag-squid","tag-squidclamav"],"_links":{"self":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=205"}],"version-history":[{"count":0,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=\/wp\/v2\/posts\/205\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ffteixeira.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}