2016年4月9日星期六

Block specific keyword in Squid Proxy squidproxy屏蔽关键字

INTRODUCTION

After learning how to block website using ban list, so now in this short guide I am going to tell you how to restrict any websites based on keywords in squid proxy server.
Blocking keywords in squid proxy server is very helpful for the system administrators in colleges and schools networks.

SOLUTION

Let’s start
Same as we make ban_domains list in my previous article, I will store all keywords in ban_keywords.txt file which you wish to block.
Step 1:
create list:
# vi /etc/squid/ban_keywords.txt
Add keywords
gambling
spyware
bad
Step 2:
Add ACL to block website by reading ban_keywords.txt file.
Edit /etc/squid/squid.conf file:
# vi /etc/squid/squid.conf
ACL:
acl bad_keywords url_regex “/etc/squid/ban_keywords.txt”
http_access deny bad_keywords
Step 3:
Restart Squid
# systemctl restart squid.service
Try to search ban keywords in search engine, you will get squid default blocked message in browser.

linux 命令之屏蔽指定域名



iptables -A OUTPUT -p tcp -m string --string "youtube.com" --algo kmp -j REJECT 

2016年4月8日星期五

轻松愉快部署squid 给你的VPS

安装squid服务

chmod +x cross_os_squid.sh
./cross_os_squid.sh
 1 部署成功会看到squid的25端口已经启动!
 
 2 crontab -e 可以查看到一个检测squid运行状态的计划任务,cron服务将每分钟检测squid 的运行状态! 
 
 3 单独创建了/squid/目录,可以看到3个脚本,cron.sh为计划任务的脚本,restart.sh为squid 服务重启的脚本
 
 start.sh为squid启动脚本,如果squid没启动可以手动执行restart.sh脚本
 
 4 可以将squid 的端口加入finalspeed 的客户端,加速端口为squid 服务的端口比如25,finalspeed 的服务器IP为squid服务器的IP! 

2016年4月5日星期二

检测squid 端口脚本

 #!/bin/bash
 #service monitoring squid3 finalspeed  vpn
 
  /bin/netstat -tulpn | awk '{print $4}' | awk -F: '{print $4}' | grep ^25$ > /dev/null   2>/dev/null
 a=$(echo $?)
 if test $a -ne 0
 then
 /etc/init.d/squid3 restart > /dev/null 2>/dev/null
 else
 sleep 0
 fi