成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

linux下用squid和squidGuard配置代理服務器

安全
網上有不少在linux中使用squid和squidGuard配置代理服務器的文章,這幾天一直在搞這么個東東網上的資料也看了不少總是覺的和自己設置的不一樣。就把我自己寫的發上來。大家可以參考也給自己留個備份。

網上有不少在linux中使用squid和squidGuard配置代理服務器的文章,這幾天一直在搞這么個東東網上的資料也看了不少總是覺的和自己設置的不一樣。就把我自己寫的發上來。大家可以參考也給自己留個備份。

1.設置網絡參數什么IP。

主機名什么的這個就不廢話了。

2.建立squid的用戶和組

groupadd squid
編輯\etc\passwd
suuid:x:500:501::/usr/local/squid:/bin/bash
用戶目錄設為/usr/local/squid
3.下載和安裝squid;Berkeley DB 2.x;squidGuard

www.squid-cache.org ;下載squid-2.4.STABLE2-src.tar.gz存在本地/usr/local/squid/src。

$cd /usr/local/squid/src
$tar xvzf squid-2.4.STABLE2-src.tar.gz
$ cd squid-2.4.STABLE2
$./configure
$make
$make install

http://www.sleepycat.com
下載db-2.7.7.tar.gz并存在/usr/local/squidGuard/src/目錄下

$su
#cd /usr/local/squidGuard/src/
#tar xvzf db-2.7.7.tar.gz
#cd db-2.7.7
#cd build_unix
#../dist/configure
#make
#make install

從http://ftp.ost.eltele.no/pub/www/proxy/squidGuard/squidGuard-1.1.4.tar.gz下載軟件包并存于本地/usr/local/squidGuard/src/

#cd /usr/local/squidGuard/src/
#tar xvzf squidGuard-1.1.4.tar.gz
#cd squidGuard-1.1.4
#./configure --with-sg-config=/usr/local/squidGuard/squidGuard.conf
--with-sg-logdir=/usr/local/squidGuard/logs
--with-sg-dbhome=/usr/local/squidGuard/db
--prefix=/usr/local/squidGuard --之間都是空格不能用回車

這個命令結束后會在你的/usr/local/squidGuard將出現文件夾db;logs;bin的目錄要是沒有出現可以用mkdir建立一個,還應該有squidGuard.conf但是我一直沒有弄出來。 
#make
#make test

測試ok,即可進行下一步安裝 測試的時候可能也會報一個錯誤好像是什么什么權限問題。可以到squidGuard-1.1.4目錄下的test下在執行一下#make test 要是這里沒有問題就可以繼續。

#make install

#p#

4.配置squid: 

修改squid的配置文件/usr/local/squid/etc/squid.conf:
http_port 8080

#squid的代理端口,使用1024以下的端口,squid必須以root身份運行
http_access allow all

#允許所有的用戶通過代理進行http訪問
redirect_program /usr/local/squid/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf

#squid啟用squidGuard進行過濾和轉發

其它參數:
cache_mem:設置代理服務使用的內存大小,一般推薦為物理內存的三分之一
cache_dir:指定cache目錄的路徑,默認為/usr/local/squid/cache。

maximum_object_size: 指定Squid可以接收的***對象的大小。Squid缺省值為4M,可以根據自己的需要進行設定。
cache_dir:設定緩存的位置、大小。

一般格式如下:
cache_dir /usr/local/squid/cache 100 16 256
/usr/local/squid/cache代表緩存的位置;100代表緩存***為100M;16和256代表一級和二級目錄數。
cache_effective_user:設定使用緩存的有效用戶。缺省為用戶nobody,如果系統中沒有用戶nobody,***建一個或以非root用戶運行Squid。這里是以squid身份運行的

cache_effective_group:設定使用緩存的有效用戶組。缺省組為nogroup,如果系統中沒有組nogroup,***建一個組。這里是squid組

5.配置squidGuard:

修改squidGuard的配置文件/usr/local/squidGuard/squidGuard.conf文件:

logdir /usr/local/squidGuard/logs

#日志目錄定義 

dbhome /usr/local/squidGuard/db  

#db目錄定義

time testtime { 

#時間規則定義 

weekly mtwhf 05:00 - 10:30
weekly as 08:00 - 19:00
date *-*-01 08:00 - 16:30
date 2001.10.01 - 2001.10.09
}

src admin {

 #源組定義  

ip 192.168.100.18
}

src client{
ip 192.168.100.20 192.168.100.21 192.168.100.22
ip 192.168.200.0/24
}

dest porn {

#目標組定義 

domainlist porn/domains
urllist porn/urls
expressionlist porn/expressions
}

acl {

#訪問規則定義 

admin within testtime {
pass !porn all
} else {
pass all
}
client {
pass !in-addr !porn all
}
default {
pass none
redirect http://admin.foo.com

(#也可以重定向到一個含有一些信息的cgi頁面,如下: 
http://admin.foo.com/cgi/blocked?clientaddr=%a&clientname=%n&clientuser=%i&clientgroup=%s&targetgroup=%t&url=%u)

}
}
 

#p#

 # vi db/porn/domains
(域列表文件:主要是阻塞一些定義的站點)
co.za
sex.com
(如上,可以阻塞如hack.co.za、sex.com、www.sex.com、whatever.sex.com,但是不同于.*[^.]sex.com,不匹配ssex.com)
# vi db/porn/urls
(url列表文件,主要是阻塞一些站點及其一些欄目)
qihui.com/sex
valen.sohu.com/album
(如上可阻塞http://qihui.com/sex、http://qihui.com/sex/whatever、ftp://qihui.com/sex、http://www.qihui.com/sex等)
 # vi db/porn/expressions
(表達式列表文件,主要是阻塞一些與表達式匹配的URL訪問)
(^|[?+=/])(.*)(girl)(.*)([?+=/]|$)
(上面的正則表達式可以阻塞URL中包括girl站點的訪問,如:www.girlzine.com、girl.huabao.net、www.huayu.net/girl、www.universiti.com/girl等 )

注意:squidGuard對配置文件的語法要求很嚴,如果配置文件語法有誤,squidGuard仍能運行,但是squidGuard已進入應急模式,此時代理服務不具有任何阻塞作用,所有通過該代理的訪問都可通過,可以查看logs/squidGuard的日志文件,即可發現錯誤,例如:

2001-12-20 17:08:44 [2430] parse error in configfile /usr/local/squidGuard/squidGuard.conf line 8
2001-12-20 17:08:44 [2430] going into emergency mode
…….
其中配置文件第8行有誤,squidGuard進入應急模式。 配置的具體說明詳見http://www.squidguard.org/

6. 運行:

$ chmod 777 /var/log/squid
$ chmod 777 /var/spool/squid
$ chmod 777 /usr/local/squid/var
$ chmod 777 /usr/local/squid/var/logs
$ chmod 777 /usr/local/squidGuard/log
$ chmod 777 /var/log/squid
(設置logs對所有用戶為可寫。這樣,不特定的squid代理客戶才能正常訪問代理服務器,并能在logs目錄、產生access.log、cache.log等文件。)

記得的好像就是這幾個文件開777權限。要是疏漏了可以看日志修改

 $ /usr/local/squid/bin/squid -z
(手工建立squid的緩存目錄/usr/local/squid/cache。)
 

#/usr/local/squid/bin/squid
 

后臺執行squid。如果想前臺執行squid:如果你想前臺執行Squid執行命令:
$/usr/local/squid/bin/squid -D
該命令正式啟動Squid。如果一切正常,你會看到一行輸出: 
Ready to serve requests 

# ps ax|grep squid
20198 ? S 0:00 /usr/local/squid/bin/squid
20200 ? S 0:27 (squid)
20310 ? S 0:00 (squidGuard) -c /usr/local/squidGuard/squidGuard.conf
20311 ? S 0:00 (squidGuard) -c /usr/local/squidGuard/squidGuard.conf
20312 ? S 0:00 (squidGuard) -c /usr/local/squidGuard/squidGuard.conf
20313 ? S 0:00 (squidGuard) -c /usr/local/squidGuard/squidGuard.conf
20314 ? S 0:00 (squidGuard) -c /usr/local/squidGuard/squidGuard.conf

此時squidGuard也已啟用,每次修改配置后squid -k reconfigure重新起用即可,要殺掉squid執行squid -k kill。

查看squidGuard日志文件:

init domainlist /usr/local/squidGuard/db/porn/domains
2001-12-20 16:14:43 [2270] init domainlist /usr/local/squidGuard/db/porn/domains
2001-12-20 16:14:43 [2270] init urllist /usr/local/squidGuard/db/porn/urls
2001-12-20 16:14:43 [2270] init expressionlist /usr/local/squidGuard/db/porn/expressions
2001-12-20 16:14:43 [2270] squidGuard 1.1.4 started (1008836083.022)
2001-12-20 16:14:43 [2270] recalculating alarm in 917 seconds
2001-12-20 16:14:43 [2270] squidGuard ready for requests (1008836083.044)
表示squidGuard已正常啟動。

7.開機自動啟動

最容易的機制之一是/etc/rc.local腳本。這是個簡單的shell腳本,在每次系統啟動時以root運行。使用該腳本來啟動squid非常容易,增加一行如下:

/usr/local/squid/sbin/squid -D
touch /var/lock/subsys/local
這個不知道什么意思別人讓加就加上了。

8.一些小經驗和大家分享一下

在開啟squid之前,你應該謹慎的驗證配置文件。這點容易做到,運行如下命令即可:%squid -k parse假如你看不到輸出,配置文件有效,你能繼續后面的步驟。

然而,如果配置文件包含錯誤,squid會告訴你:squid.conf line 62: http_access allow okay2    aclParseAccessLine: ACL name 'okay2' not found.這里你可以看到,62行的http_access指令指向的ACL不存在。有時候錯誤信息很少:FATAL: Bungled squid.conf line 76: memory_pools在這個情形里,我們忘記了在76行的memory_pools指令后放置on或off.

建議你養成習慣:在每次修改配置文件后,使用squid -k parse。假如你不愿麻煩,并且你的配置文件有錯誤,squid會告訴你關于它們而且拒絕啟動。假如你管理著大量的cache,也許你會編輯腳本來自動啟動,停止和重配置squid。你能在腳本里使用該功能,來確認配置文件是有效的。

保存日志vi /etc/logrotate.d/squid/var/log/squid/access.log

{    weekly    
       rotate 52    .
       copytruncate    
       compress    
       notifempty    
       missingok
}
/var/log/squid/cache.log {    
       weekly  
        rotate 52  
        copytruncate    
        compress    
        notifempty
         missingok
}
/var/log/squid/store.log {    
        weekly    
        rotate 52    
        copytruncate    
        compress  
         notifempty    
         missingok    
         postrotate   /usr/local/squid/sbin/squid -k
         rotate  
          endscript

}

***需要注意的是DNS設置。還有就是權限。這個很重要。squid起不來的原因我覺的80%都是權限的問題。這樣可以保存你的日志文件啦。

原文來自:http://netdl.blog.51cto.com/184762/33118

【編輯推薦】

  1. Linux下通過WebShell反彈Shell的技巧
  2. SquidClamAv 6.0 發布(含下載)
  3. squid2.6stable12+clamav+havp搭建防毒代理
  4. Linux下Squid代理服務器的架設與維護(一)
責任編輯:佟健 來源: 51CTO博客
相關推薦

2012-09-18 09:55:28

2020-08-02 15:00:40

SquidSSH系統運維

2009-12-03 18:07:48

Squid代理服務器

2011-02-21 09:24:05

2019-06-18 08:27:37

Squid代理服務器IP代理池

2009-02-06 10:54:00

Necsocks5Windows代理服務代理服務器

2024-11-21 09:18:08

2009-02-12 15:51:00

squid代理服務器web服務器

2009-12-16 16:41:44

Linux代理服務器

2018-11-05 09:34:43

2009-02-10 15:42:00

代理服務器代理服務器設置

2009-07-06 10:26:32

2024-02-20 14:53:01

2011-09-02 09:47:17

Linux服務器

2009-02-12 14:04:00

代理服務器LINUX架設服務器

2015-07-17 10:45:42

Squid服務器訪問控制系統

2009-02-12 15:36:00

免費代理服務器代理服務器代理服務器設置

2009-02-12 15:58:00

linuxwindows域代理服務器

2009-08-18 11:04:50

代理服務器設置代理服務器地址

2011-04-20 16:59:31

點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 欧美一级二级三级视频 | 99re在线视频| 国产精品免费一区二区三区四区 | 精品日韩 | 日本精品久久久久久久 | 亚洲精品亚洲人成人网 | 国产精品色一区二区三区 | 亚洲人成在线播放 | 成人免费视频观看 | 7777精品伊人久久精品影视 | 国产精品久久久久久久久久久免费看 | 国产在线区 | 亚洲一区二区免费视频 | 精品视频一区二区 | www.操.com| 91亚洲精华国产 | 日本色婷婷 | 精品一区二区三区中文字幕 | 性色综合| 亚洲精品久久嫩草网站秘色 | 红桃视频一区二区三区免费 | 久久成人精品视频 | 国产在线小视频 | 福利网站导航 | 免费成人高清在线视频 | 日本不卡视频 | 91大神在线资源观看无广告 | 亚洲欧美国产精品久久 | 日日干夜夜干 | 亚洲成人免费 | 亚洲欧洲综合av | 91在线免费视频 | 97色在线视频 | 国产欧美精品 | 久久综合九色综合欧美狠狠 | 每日更新av | 国产精品成人一区二区三区 | 两性午夜视频 | 亚洲精品v| 一区日韩 | 超碰地址 |