acl,禁止資源訪問,squid


squid禁用mp4規則:
 acl mp4_url url_regex -i \.mp4$
http_access deny mp4_url
===============
http://guanjianfeng.com/archives/322923

利用squid的acl控制語句來控制某些站點的訪問,前幾天在網絡改造時一直沒有成功。在squid.conf中acl字段如下:

acl web src 192.168.20.0/24
http_access allow web 
acl badsite dstdomain 17lele.com 
acl badurl url_regex -i sex
http_access deny badsite
http_access deny badurl
acl all src 0.0.0.0/0.0.0.0
http_access deny all

今天剛看了CNFUG十六期Horus的一篇文章–在FreeBSD上安裝Squid,才再次去試着改一下,最后明白:上次我是裝禁止站點的語句加在了

acl web src 192.168.20.0/24
http_access allow web

的后面,所以就省略了我新加的這兩句。所以我將badsite和badurl字段的兩句放到前面,重啟,成功禁止了17lele.com和帶sex字段的網址。如下:

acl badsite dstdomain 17lele.com 
acl badurl url_regex -i sex
http_access deny badsite
http_access deny badurl
acl web src 192.168.20.0/24
http_access allow web 
acl all src 0.0.0.0/0.0.0.0
http_access deny all

 

附上acl語句詳細說明:

ACL,Access Control List,訪問控制列表.它的語法是: (在/usr/local/squid/etc/squid.conf里添加) 
acl 表名 表類型 [-i] 表的值
http_access [allow/deny] 表名下面分條解釋:
表名:可以自定義
表類型:表類型有
src 源地址:客戶機的IP地址
dst 目的地址:服務器的IP地址
srcdomain 源域:客戶機所屬的域
dstdomain 目的域:服務器所屬的域 
url_regex URL正則表達式(字符串部分)
urlpath_regex URL正則表達式中的路徑
time [星期] [時間段]
maxconn 客戶端的最大連接數
-i 這個參數使Squid不區分大小寫
表的值:隨表的類型不同而不同
注意:time中的星期要用如下字符:
S (Sunday,星期日) M(Monday,星期一) T(Tuesday,星期二) W(Wednesday,星期三)
H(Thursday,星期四) F(Friday,星期五) A(Saturday,星期六)
時間段的表示方式是: XX:00-YY:00 如: 20:00-22:00
http_access 選項允許你設置一個表是允許(allow)還是拒絕(deny)
下面舉幾個例子: 防3721的ACL.在squid.conf中加入: 
acl badurls dstdomain -i www.3721.com www.3721.net download.3721.com cnsmin.3721.com
http_access deny badurls
acl badkeywords url_regex -i 3721.com 3721.net
http_access deny badkeywords
解釋: 
badurls 和 badkeywords 是你自定義的表名. 
dstdomain 是服務器的域名(目的域) 而 url_regex 則是URL正則表達式(字符串部分)包含的內容. 
http_access 選項的 deny 則是把表badurls和表badkeywords的訪問拒絕. 
禁止下載Flash: 
acl badfiles urlpath_regex -i .swf$ 
http_access deny badfiles
大家在今后的配置中,慢慢體會ACL的用法吧! 達到目的嘍: 
錯誤 
您所請求的網址(URL)無法獲取 
——————————————————————————–
當嘗試讀取以下網址(URL)時: 
http://www.3721.com/ 發生了下列的錯誤: 
Access Denied. 拒絕訪問 
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect. 當前的存取控制設定禁止您的請求被接受,如果您覺得這是錯誤的,請與您網路服務的提供者聯系。 本緩存服務器管理員:guanjianfeng@jscpu.com

 

附上acl語句詳細說明:

ACL,Access Control List,訪問控制列表.它的語法是: (在/usr/local/squid/etc/squid.conf里添加) 
acl 表名 表類型 [-i] 表的值
http_access [allow/deny] 表名下面分條解釋:
表名:可以自定義
表類型:表類型有
src 源地址:客戶機的IP地址
dst 目的地址:服務器的IP地址
srcdomain 源域:客戶機所屬的域
dstdomain 目的域:服務器所屬的域 
url_regex URL正則表達式(字符串部分)
urlpath_regex URL正則表達式中的路徑
time [星期] [時間段]
maxconn 客戶端的最大連接數
-i 這個參數使Squid不區分大小寫
表的值:隨表的類型不同而不同
注意:time中的星期要用如下字符:
S (Sunday,星期日) M(Monday,星期一) T(Tuesday,星期二) W(Wednesday,星期三)
H(Thursday,星期四) F(Friday,星期五) A(Saturday,星期六)
時間段的表示方式是: XX:00-YY:00 如: 20:00-22:00
http_access 選項允許你設置一個表是允許(allow)還是拒絕(deny)
下面舉幾個例子: 防3721的ACL.在squid.conf中加入: 
acl badurls dstdomain -i www.3721.com www.3721.net download.3721.com cnsmin.3721.com
http_access deny badurls
acl badkeywords url_regex -i 3721.com 3721.net
http_access deny badkeywords
解釋: 
badurls 和 badkeywords 是你自定義的表名. 
dstdomain 是服務器的域名(目的域) 而 url_regex 則是URL正則表達式(字符串部分)包含的內容. 
http_access 選項的 deny 則是把表badurls和表badkeywords的訪問拒絕. 
禁止下載Flash: 
acl badfiles urlpath_regex -i .swf$ 
http_access deny badfiles
大家在今后的配置中,慢慢體會ACL的用法吧! 達到目的嘍: 
錯誤 
您所請求的網址(URL)無法獲取 
——————————————————————————–
當嘗試讀取以下網址(URL)時: 
http://www.3721.com/ 發生了下列的錯誤: 
Access Denied. 拒絕訪問 
Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect. 當前的存取控制設定禁止您的請求被接受,如果您覺得這是錯誤的,請與您網路服務的提供者聯系。 本緩存服務器管理員:guanjianfeng@jscpu.com

 
=====================
http://qubaoquan.blog.51cto.com/1246748/292605

RedHat linux 系統默認已經安裝了squid 
1.squid代理服務的配置

有以下最基本的設置squid就可以啟動使用了

http_port 192.168.0.110:8080

cache_mem 64 MB

cache_dir ufs /var/spool/squid 4096 16 256

cache_effective_user squid

cache_effective_group squid

dns_nameservers 192.168.0.1

cache_access_log /var/log/squid/access.log

cache_log /var/log/squid/cache.log

cache_store_log /var/log/squid/store.log

visible_hostname 192.168.0.110

cache_mgr qubaoquan@ccpower.com.cn

acl all src 0.0.0.0/0.0.0.0

http_access allow all

1.1 指定squid服務器監聽的ip和端口

http_port 192.168.0.110:8080

1.2 設置內存緩沖的大小(僅僅用於共享上網設為物理內存的1/2,如果還有其他服務責不應超過物理內存的1/3

cache_mem 64 MB

1.3 設置內存盤緩沖的大小

cache_dir ufs /var/spool/squid 4096 16 256

Ufs 是指緩沖的存貯類型,/var/spool/squid是存貯目錄,4096代表最大存貯空間,16代表一級存貯目錄,256代表二級存貯目錄

1.4 設置使用存貯的有效用戶和組

cache_effective_user squid

cache_effective_group squid

1.5 定義DNS服務器地址

\ dns_nameservers 192.168.0.1

1.6 設置訪問日志文件

cache_access_log /var/log/squid/access.log

1.7 設置緩存日志文件

cache_log /var/log/squid/cache.log

1.8 設置網頁緩沖日志文件

cache_store_log /var/log/squid/store.log

1.9 設置運行squid主機的名稱

visible_hostname 192.168.0.110

1.10 設置管理員郵件地址

cache_mgr qubaoquan@ccpower.com.cn

1.11 設置默認的訪問控制列表

acl all src 0.0.0.0/0.0.0.0

http_access allow all

2.初始化squid /usr/sbin/squid –z(創建squid在硬盤緩沖區的目錄結構)

3.訪問控制列表

類型選項

命令

說明

src

IP地址(客戶機IP地址)

dst

目標IP地址(服務器IP地址)

srcdomain

源名稱(客戶機所屬的域)

dstdomain

目標名稱(服務器所屬的域)

time

一天中的時刻和一周內的一天

url_regex

URL規則表達式匹配

urlpath_regex:url-path

略去協議和主機名的URL規則表達式匹配

proxy_auth

通過外部程序進行用戶認證

maxconn

單一IP的最大連接數

time

語法為:時間 時間段 星期可用首字母大寫表示,時間段可表示為:1100-2000

 

列表語法:acl 列表名稱 列表類型 –i 列表值

http_access allow/deny 列表名稱

實際應用舉例

(1) 禁止IP地址為192.168.16.200的客戶機上網

acl test src 192.168.16.200

http_access deny test

(2) 禁止192.168.1.0這個網段里的所有客戶機上網

acl test src 192.168.1.0/255.255.255.0

http_access deny test

http_access deny test

(3) 禁止用戶訪問IP210.21.118.68的網站

acl test dst 210.21,118.68

http_access deny test

(4) 禁止用戶訪問域名為www.163.com的網站

acl test dstdomain –i www.163.com

http_access deny test

(5) 禁止用戶訪問域名包含有163.com的網站

acl test url_regex –i 163.com

http_access deny test

(6) 禁止用戶訪問包含有sex關鍵字的URL

acl test url_regex –i sex

http_access deny test

(7) 限制IP地址為192.168.16.200的客戶機並發的最大連接數為5

acl test src 192.168.16.200

acl test2 maxconn 5

http_access deny test test2

(8) 禁止192.168.2.0這個子網里所以客戶機在周一至周五的9點到18點上網

acl test src 192.168.2.0 /255.255.255.0

acl test2 time MTWHF 900-1800

http_access deny test test2

(9) 禁止用戶下載*.mp3,*.exe,*.zip,*.rar

acl test urlpath_regex –i \.mp3$\.exe$\.zip$\.rar$

http_access deny test

(10) 禁止QQ通過squid上網

acl test url_regex –i tencent.com

http_access deny test

注:啟動squid/etc/init.d/squid start

停止squid /etc/init.d/squid stop

重啟squid /etc/init.d/squid restart

重新導入配置文件 /etc/init.d/squid reload

4.透明代理的實現

1實現透明代理的語句(vi /etc/squid/squid.conf

http_accel_host virtual

http_accel_port 80

http_accel_with_proxy 0n

httpd_accel_uses_host_header 0n

http_accel_hosthttp_accel_port來定義squid的加速模式,virtual是虛擬主機模式,80為請求的端口

http_accel_with_proxy 選項定義為on后,squid既是web請求的加速器又是緩存代理服務器

httpd_accel_uses_host_header定義為on后,在透明代理模式下代理服務器的緩存功能才能工作

2設置端口重定向

iptables –t nat –A PREROUTING -s 192.168.1.0/24 -p tcp --dport 80 -j REDIRECT --to-ports 8080

(3) 重新導入配置文件 /etc/init.d/squid reload

配置用戶身份驗證

1. 配置/etc/squid/squid.conf(NCSA認證)

auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/passwd

auth_param basic children 5

auth_param basic credentialsttl 2 hours

auth_param basic realm Example.com's Squid proxy-caching

acl auth_user proxy_auth REQUIRED

http_access allow auth_user

auth_param basic program選項定義了認證方式為basic/usr/lib/squid/ncsa_auth /etc/squid/passwd定義了認證程序的路徑和讀取的賬戶文件

auth_param basic children 定義了認證程序的進程數

auth_param basic credentialsttl 定義了經過認證后的有效時間

auth_param basic realm 定義了WEB 瀏覽器顯示輸入用戶/密碼對話框的領域內容

acl auth_user proxy_auth REQUIREDhttp_access allow auth_user設置合法用戶的訪問控制列表

2. 建立賬戶文件

htpasswd -c /etc/squid/passswd test(建第一個用戶時要用-c選項)

htpasswd /etc/squid/passswd test2

htpasswd /etc/squid/passswd test3

3. 重新啟動squid服務

 

http://tanxin.blog.51cto.com/6114226/1254878

Squid三種代理方式的實現及ACL

操作環境:(Redh5.8)

Client:192.168.8.70          (如圖:機器為8.70)

Squid:192.168.8.71(eth0)   (如圖:機器為8.71)

      172.16.1.16(eth1)   (如圖: 機器為8.72)

Web:  172.16.1.17

圖:

(注:實驗過程中涉及的dns相關內容沒有做)

Squid的主要功能:

1.支持HTTP,FTP協議

2.采用層次化緩存結構

3.支持代理SSL

4.實現了ICP(Internet緩存協議,HTCP(超文本緩存協議)等)

5.支持透明代理

6.支持WCCP(Web緩存通信協議)

7.支持豐富的訪問控制列表功能

8.支持HTTP加速功能,實現反向代理

9.支持SNMP

10.支持緩存DNS查詢

 

一.正向代理(標准代理)

 

 1. 一個標准的代理緩沖服務被用於緩存靜態的網頁(例如:html文件和圖片文件等)到本地網絡上的一台主機上(即代理服務器)。當被緩存的頁 面被第二次訪問的時候,瀏覽器將直接從本地代理服務器那里獲取請求數據而不再向原web站點請求數據。這樣就節省了寶貴的網絡帶寬,而且提高了訪問速度。

2. 訪問過程(如上圖)

@1.客戶端使用某一端口連接代理服務器3128端口,請求web頁面(連接的網卡為eth0)


@2.代理服務器向DNS請求得到相應的IP地址,然后,代理服務器使用某一端口,向該IP地址的80端口發起web連接請求,請求web頁面。(連接的網卡為eht1)

@3.~@5收到響應的web頁面后,代理服務器把該數據傳送給客戶端。並查看自己有沒有緩存,若沒有緩存一份


@6.~@7.當客戶端再次訪問時,直接通過緩存返給客戶端信息

3.具體配置

(1)裝包

[root@tx2 ~]# yum install -y squid

(2)開啟包轉發

[root@tx2 ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 1

 

(3)修改配置文件

[root@tx2 ~]# vim /etc/squid/squid.conf

637  http_access allow all         //給所有的客戶端開啟代理服務

921  http_port 192.168.8.71:3128     //設置squid監聽的端口//192.168.8.71的ip是squid與客戶端鏈接的網卡的ip地址。

1579 cache_mem 8 MB     設定squid占用的物理內存,一般為物理內存的1/3(代表squid能使用多少內存,如果你的內存足夠可以調的稍微大一些)

 

1786 cache_dir ufs /var/spool/squid 100 16 256  設定緩存的位置

       @1.ufs  :同步,有請求過來先把得到的數據寫入磁盤再處理請求

       @2.aufs :異步,先響應請求再把數據寫入磁盤

       @3.100  :M,緩存的數據大小

       @4.16   :1級子目錄的數量

       @5.256  :2級子目錄的數量

1842    cache_swap_low 90   最低“水位線“

//95:代表cache 占用swap的空間最多是百分之95,如果大於百分之95,squid會自動刪除之前保存的數據

 

1843 cache_swap_high 95  最高“水位線“

//90: 代表刪除的時候還是會保存最新的百分之90

 

2974 cache_effective_user squid  通知系統是以squid用戶的身份去執行

 

4. 配置web端的http服務

 

#yum install -y httpd

#cd /var//ww/html

#echo “helo tx” > index.html

#/etc/init.d/httpd start

 

5. 配置client端的瀏覽器

@1.點擊edit,然后點擊edit下的Preferences

@2.點擊Advanced----->Network-------->Settings

@3.如圖所示

配置完成

 

6.client端測試

二.Squid的透明代理

 1.透明代理緩沖服務和標准代理服務器的功能完全相同。但是,代理操作對客戶端的瀏覽器是透明的(即不需指明代理服務器的IP和端口)。透明代 理服務器阻斷網絡通信,並且過濾出訪問外部的HTTP(80端口)流量。如果客戶端的請求在本地有緩沖則將緩沖的數據直接發給用戶,如果在本地沒有緩沖則 向遠程web服務器發出請求,其余操作和標准的代理服務器完全相同。

  2訪問過程

@1.客戶端向DNS請求,得到相應的IP地址。然后,客戶端使用某一端口,向該IP地址的80端口發起web連接請求,請求web頁面。


@2~@3.當該請求包通過透明代理服務器時,被防火牆將該數據包重定向到代理服務器的綁定端口3128。於是,透明代理服務器用某一端口發起web連接請求,請求web頁面。


@4~@5收到響應的web頁面后,代理服務器把該數據傳送給客戶端。並查看自己有沒有緩存,若沒有緩存一份


@6.~@7.當客戶端再次訪問時,直接通過緩存返給客戶端信息

 

3.具體配置

(1)修改配置文件

[root@tx2 ~]# vim /etc/squid/squid.conf

http_port 192.168.8.71:3128 transparent

(2)配置防火牆規則

[root@tx2 ~]# iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128

//所有192.168.0.0這個網段訪問squid的80端口,都由防火牆轉發到3128的squid服務端口

 

[root@tx2 ~]# iptables -t nat -L

Chain PREROUTING (policy ACCEPT)

target     prot opt source               destination        

REDIRECT   tcp  --  192.168.0.0/24       anywhere            tcp dpt:http redir ports 3128

 

Chain POSTROUTING (policy ACCEPT)

target     prot opt source               destination        

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination        

[root@tx2 ~]# iptables -t nat -F

[root@tx2 ~]# service squid restart

Stopping squid: ................                           [  OK  ]

Starting squid: .                                          [  OK  ]

(3)客戶端取消代理

(4)配置客戶端網觀

[root@tx1 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

添加GATEWAY=“squid的ip”

[root@tx1 ~]# /etc/init.d/network restart

(5)測試

三.反向代理(web加速)

    1.反向代理是和前兩種代理完全不同的一種代理服務。使用它可以降低原始WEB服務器的負載。反向代理服務器承擔了對原始WEB服務器的靜態頁 面的請求,防止原始服務器過載。

2.訪問過程

@1.客戶端通過瀏覽器向DNS服務器發送請求,由客戶所在地的DNS服務器解析IP地址,並將結果返回給用戶。


@2.客戶收到DNS返回的服務器IP地址,重新向DNS服務器指向的IP地址發送訪問請求。

 

@3.squid 服務器接收到用戶的請求后,查詢自身緩存中是否有用戶請求內容,有則直接發送給客戶端

@4. 有則通過內部DNS輪詢查詢空閑服務器,並將客戶請求發送到 該服務器,在獲取到用戶數據並返回給用戶的同時保留一份在自己本身的緩存當中。

 

在用戶看來,自己訪問的是www.96333.com這個服務器,實際上真 正的WEB服務器為SQUID緩存后面的服務器或者服務器集群,通過外部DNS做CNAME轉向,將用戶請求轉發到內部真正的web服務器上去。

 

3.具體配置

(1)[root@tx2 ~]# vim /etc/squid/squid.conf

923 http_port 80 transparent

924 cache_peer 172.16.1.17 parent 80 0 originserver no-query name= www

originserver 源點服務器

no-query     不詢問

name=www     用來區分相似的查詢

(其他選項不變)

(2)測試

四.訪問控制(ACL)

1.ACL元素

語法定義如下:

acl aclname acltype string1

acl aclname acltype "file"

//acltype可以是(src、dst、srcdomain、dstdomain、url_regex、urlpath_regex、time、port、proto、method)

 

(1) src:源地址。定義如下:

acl aclname src ip-address/netmask ... 客戶ip地址

acl:aclname src addr1-addr2/netmask ... 地址范圍

 

(2)dst:目標地址

acl aclname dst ip-address/netmask ...

 

(3)srcdomain:客戶所屬的域

acl aclname srcdomain foo.com ...

 

(4)dstdomain:請求服務器所屬的域

acl aclname dstdomain foo.com ...

 

(5)time:訪問時間

acl aclname time [day-abbrevs] [h1:m1-h2:m2][hh:mm-hh:mm]

1 S:指代Sunday

2 M:指代Monday

3 T:指代Tuesday

4 W:指代Wednesday

5 H:指代Thursday

6 F:指代Friday

7 A:指代Saturday

 

(6)port:訪問端口。可以指定多個端口

acl aclname port 80 70 21 ...

acl aclname port 0-1024 ... 指定一個端口范圍

 

(7)proto:使用協議

acl aclname proto HTTP FTP ...

 

(8)method:請求方法

acl aclname method GET POST ...

 

(9)url_regex:URL規則表達式匹配

acl aclname url_regex[-i] pattern

 

(10)urlpath_regex:URL-path規則表達式匹配

acl aclname urlpath_regex[-i] pattern

 

2.http_access訪問控制列表

根據訪問控制列表允許或禁止某一類用戶訪問。最后的條目設為“deny all”或“allow all”來避免安全性隱患。http_access Action聲明1 AND 聲明2 AND多個,http_access聲明間用或運算連接,但每個訪問條目的元素間用與運算連接,列表中的規則總是遵循由上而下的順序。

3.實例應用

(1)禁止IP地址為192.168.8.200的客戶機上網

acl client src 172.16.1.2

http_access deny client

 

(2)禁止網段10-50上網

 

acl client src 172.16.1.10-172.16.1.50/32

http_access deny client

 

(3)拒絕訪問web的ip

acl client dst 192.168.1.2

http_access deny client

 

(4)限制URL以 某些內容 開頭

acl client url_regex index

http_access deny client

 

(5)限制URL 以 某些內容 結尾

 

acl client urlpath_regex \.html

http_access deny client

 

(6)限制時間段

acl client time MTWHFA 9:00-18:00

http_access deny client

 

(7)限制443端口上網

acl http port 443

http_access deny http

 

(8)限制用戶並發連接數為:5

acl clientsrc 172.16.1.15

acl conn5 max 5

http_access deny client conn5

 

(9)禁止下載*.mp3$ *.exe$ *.zip$ *.rar$ *.doc$類型的文件

acl client  urlpath_regex -i \.mp3$ \.exe$ \.zip$ \.rar$ \.doc$

http_access deny client

注:這些訪問控制可以根據實際情況加到上面的三種代理方式中,訪問控制要寫的有意義

本文出自 “tanxin” 博客,請務必保留此出處http://tanxin.blog.51cto.com/6114226/1254878

 

 

http://bbs.51cto.com/archiver/tid-1094430.html

squid服務器里的ACL控制沒起作用...

squid.conf



#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# 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/16 # RFC1918 possible internal network
acl localnet src 192.168.10.0/24 # 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 pm_equipment src "/etc/squid/ip_server"
#acl pm_qiantai src "/etc/squid/ip_special"  #設置內網IP列表
#acl pm_backup src "/etc/squid/ip_limited"   #設置內網IP列表 
acl pm-dhcp src "/etc/squid/ip_dhcp"
acl deny_ip dst "/etc/squid/deny_ip"
#設置禁止訪問外網的IP
acl deny_dns dstdomain "/etc/squid/deny_dns"
#設置禁止訪問的域名
#acl deny_urlpath urlpath_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$
acl deny_urlpath urlpath_regex -i "/etc/squid/deny_urlpath"
#設置禁止訪問包含關鍵字的url,如:\.jpg$
acl deny_url url_regex -i "/etc/squid/deny_url"
#設置禁止訪問的url,如^">http://
acl deny_urlhead dstdom_regex -i "/etc/squid/deny_urlhead"
#設置禁止訪問某些關鍵字開頭的網址,如:^game
acl deny_downfile url_regex -i "/etc/squid/deny_downfile"
#設置禁止下載的文件類型,如:\.mp3$ \.vbs$ \.rmvb$
acl server_time time SMTWHFA 01:00-24:00
#設置服務器連網時間 



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


acl pmfsip src 192.168.10.240
acl pmfsmac arp 00:0C:29:CE:EC:5F
http_access deny pmfsmac !pmfsip
http_access deny !pmfsmac pmfsip


#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
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
#允許特殊用戶使用443端口,但不能上網
#http_access allow pm_qiantai SSL_ports
#服務器上網時間
http_access allow pm_equipment server_time
http_access deny deny_ip
http_access deny deny_dns
http_access deny deny_url
http_access deny deny_urlpath !all
http_access deny deny_downfile
http_access deny deny_urlhead
http_access allow pm-dhcp




# And finally deny all other access to this proxy
http_access allow all

# Squid normally listens to port 3128
http_port 192.168.10.240:8080 transparent

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?




# 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


#禁止緩存  URL中有包含cgi-bin和https:\\開頭的都不緩存,asp、cgi、php等動態腳本不緩存
hierarchy_stoplist -i ^https:\\ ?                               
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex -i cgi-bin \? \.asp \.php \.jsp \.cgi
acl denyssl urlpath_regex -i ^https:\\
no_cache deny QUERY
no_cache deny denyssl

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 2048 16 256


#設置硬盤緩沖位置大小存儲類型,注意:加粗的這個值一定要比cache_mem大,不然會報錯。
cache_mem 1024 MB #指定緩沖內存大小(根據服務器配置以及需要來配置,一般設置1/3-1/2倍的內存大小即可)
cache_swap_low 90 #最低緩存率百分比
cache_swap_high 95 #最高緩存率百分比,當高速緩存占用到95%時,自動減小到90%
maximum_object_size 4096 KB #設置squid磁盤緩存最大文件,超過4M的文件不保存到硬盤
minimum_object_size 0 KB #設置squid磁盤緩存最小文件
maximum_object_size_in_memory 4096 KB #設置squid內存緩存最大文件,超過4M的文件不保存到內存

#dns_children 10  #設置DNS查詢程序的進程數,默認是5,據說最高是32
redirect_children 100 #指定squid應該開啟多少重定向進程,默認值是5個進程
ipcache_size 1024  #DNS解析后的IP放在緩存中,可免去重復查詢DNS,提高訪問速度
ipcache_low 90
ipcache_high 95
fqdncache_size 1024

#設置主機名
visible_hostname pmproxy
#設置報錯為中文
error_directory /usr/share/squid/errors/zh-cn
#設置訪問日志
cache_access_log /var/log/squid/access.log  
    
cache_log /var/log/squid/cache.log
#設置緩存日志
logfile_rotate 6 
#設置日志輪轉,6表示會生成0~6共7個日志文件
cache_mgr [email=admin@ojc.com]admin@admin.com[/email]
#設置管理員郵箱
forwarded_for off  
#不傳遞被代理地址      
via off
#不傳遞代理服務器信息



deny_urlpath
\.jpg$


deny_dns
[url=www.baidu.com]www.baidu.com[/url]
[url=www.sina.com.cn]www.sina.com.cn[/url]


虛擬機兩個網卡
內網192.168.10.240
外網172.16.10.240


另一個虛擬機IP設置為
192.168.10.241
255.255.255.0
192.168.10.240

DNS
192.168.10.240

可這台機還是能訪問baidu,sina,和下載圖片...
不知哪里設置有問題了,請教各位大大. 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM