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

Squid+iptables代理配置

運維 系統運維
Squid+iptables代理配置:iptables是基于Linux內核的防火墻,iptables的功能比較強大。本文詳細介紹了Squid+iptables代理配置。

Squid+iptables代理配置

  Squid代理服務器簡介

  Squid是一種在Linux系統下使用的優秀的代理服務器軟件。

  squid不僅可用在Linux系統上,還可以用在AIX、Digital Unix、FreeBSD、HP-UX、Irix、NetBSD、Nextstep、SCO和Solaris等系統上。

  Squid是一個緩存internet數據的一個軟件,它接收用戶的下載申請,并自動處理所下載的數據。也就是說,當一個用戶象要下載一個主頁時,它向Squid發出一個申請,要Squid替它下載,然后Squid 連接所申請網站并請求該主頁,接著把該主頁傳給用戶同時保留一個備份,當別的用戶申請同樣的頁面時,Squid把保存的備份立即傳給用戶,使用戶覺得速度相當快。

  對于Web用戶來說,Squid是一個高性能的代理緩存服務器,可以加快內部網瀏覽Internet的速度,提高客戶機的訪問命中率。Squid不僅支持HTTP協議,還支持FTP、gopher、SSL和WAIS等協議。

  實驗環境:

  系統 redhat linux 5.4

  外網 eth0:192.168.0.1

  內網 eth1:192.168.1.254

  Squid Cache: Version 3.1.7

  RPM安裝,這里就不說明了。

  修改配置文件

  1.   [root@a ~]# cat /etc/squid/squid.conf  
  2.  

#p#

  配置文件說明

  定義acl訪問控制元素:ip地址、端口

  1.   acl manager proto cache_object  
  2.  
  3.   acl localhost src 127.0.0.1/32 ::1  
  4.  
  5.   acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1  
  6.  
  7.   acl localnet src 10.0.0.0/8 # RFC1918 possible internal network  
  8.  
  9.   acl localnet src 172.16.0.0/12 # RFC1918 possible internal network  
  10.  
  11.   acl localnet src 192.168.0.0/16 # RFC1918 possible internal network  
  12.  
  13.   acl localnet src fc00::/7 # RFC 4193 local private network range  
  14.  
  15.   acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines  
  16.  
  17.   acl SSL_ports port 443  
  18.  
  19.   acl Safe_ports port 80 # http  
  20.  
  21.   acl Safe_ports port 21 # ftp  
  22.  
  23.   acl Safe_ports port 443 # https  
  24.  
  25.   acl Safe_ports port 70 # gopher  
  26.  
  27.   acl Safe_ports port 210 # wais  
  28.  
  29.   acl Safe_ports port 1025-65535 # unregistered ports  
  30.  
  31.   acl Safe_ports port 280 # http-mgmt  
  32.  
  33.   acl Safe_ports port 488 # gss-http  
  34.  
  35.   acl Safe_ports port 591 # filemaker  
  36.  
  37.   acl Safe_ports port 777 # multiling http  
  38.  
  39.   acl CONNECT method CONNECT  
  40.  
  41.   acl worktime time 8:00-23:59 //定義工作時間  
  42.  
  43.   acl worktime time 00:00-5:59  
  44.  
  45.   http_access allow mynetwork !worktime //只允許非工作時間上網  
  46.  

#p#

  訪問控制設置

  1.   http_access allow manager localhost  
  2.  
  3.   http_access deny manager  
  4.  
  5.   # Deny requests to certain unsafe ports  
  6.  
  7.   http_access deny !Safe_ports 禁止非安全端口的訪問  
  8.  
  9.   # Deny CONNECT to other than secure SSL ports  
  10.  
  11.   http_access deny CONNECT !SSL_ports  
  12.  
  13.   http_access allow localnet  
  14.  
  15.   http_access allow localhost  
  16.  
  17.   # And finally deny all other access to this proxy  
  18.  
  19.   http_access allow all ***一條http_access設置默認訪問規則  
  20.  
  21.   # Squid normally listens to port 3128  
  22.  
  23.   http_port 192.168.1.254:3128 transparent 代理服務器監聽的地址及端口,transparent 為透明代理模式  
  24.  
  25.   # We recommend you to use at least the following line.  
  26.  
  27.   hierarchy_stoplist cgi-bin ?  
  28.  
  29.   # Uncomment and adjust the following to add a disk cache directory.  
  30.  
  31.   cache_dir ufs /var/spool/squid 1000 8 128 配置緩存文件的文件格式,緩存大小,緩存目錄數  
  32.  
  33.   # Leave coredumps in the first cache dir  
  34.  
  35.   coredump_dir /var/spool/squid  
  36.  
  37.   # Add any of your own refresh_pattern entries above these.  
  38.  
  39.   refresh_pattern ^ftp: 1440 20% 10080  
  40.  
  41.   refresh_pattern ^gopher: 1440 0% 1440  
  42.  
  43.   refresh_pattern -i (/cgi-bin/|\?) 0 0% 0  
  44.  
  45.   refresh_pattern . 0 20% 4320  
  46.  
  47.   visible_hostname 192.168.1.254  
  48.  
  49.   cache_mem 128 MB //squid服務器占用內存大小  
  50.  
  51.   forwarded_for off //不傳遞被代理地址  
  52.  
  53.   via off //不傳遞代理服務器信息  
  54.  

  初始化squid代理服務器

  1.   squid -z  
  2.  

  開啟路由功能,并將下面的命令寫入/etc/rc.d/rc.local 文件,使其開機自動開啟路由功能

  1.   echo '1' >/proc/sys/net/ipv4/ip_forward  
  2.  

#p#

  配置iptables防火墻

  自動將http請求轉發到代理服務器上

  1.   iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-ports 3128  
  2.  

  設置源地址映射

 

  1.   iptables -t nat -A POSTROUTING -j SNAT --to-source 192.168.1.254 (外網地址)  
  2.  
  1.   iptables -P INPUT ACCEPT  
  2.  

  啟動squid代理服務

  1.   [root@a ~]# service squid restart  
  2.  

  查看squid代理服務器緩存日志

  1.   [root@a ~]# tail -f /var/log/squid/access.log  
  2.  

  個人感覺使用Squid+iptables緩存服務器之后網頁訪問速度有大幅度的加快。

【編輯推薦】

Iptables 配置指南

iptables常用命令及參數

Iptables 詳細介紹

責任編輯:zhaolei 來源: liusuping
相關推薦

2011-03-15 10:22:02

squidiptables

2011-03-16 11:20:26

2009-11-30 13:26:25

Suse代理SQUID

2012-09-18 09:55:28

2020-08-02 15:00:40

SquidSSH系統運維

2010-11-15 14:46:04

linuxsquidsquidGuard

2019-06-18 08:27:37

Squid代理服務器IP代理池

2011-03-15 09:46:31

2011-03-15 14:01:13

2010-07-20 16:36:33

2011-02-21 09:24:05

2009-12-03 18:07:48

Squid代理服務器

2010-09-10 16:19:59

Squid 3.0Squid 2.7

2011-03-17 16:31:12

2011-03-16 11:08:58

2013-02-28 13:18:08

2011-03-14 14:40:10

2011-03-16 16:29:27

保存iptables

2009-11-30 09:56:16

2014-07-24 10:17:25

CentOSSquid
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久久久国产一区二区三区四区小说 | 天天插天天干 | 亚洲一区二区三区免费在线 | 国产精品日产欧美久久久久 | 久久久久久久久久久久一区二区 | zzzwww在线看片免费 | 91传媒在线观看 | 国产精品国产亚洲精品看不卡15 | 久操av在线 | 91精品国产日韩91久久久久久 | 亚洲一区视频在线 | 久久成人人人人精品欧 | 国产一区二区久久 | 国产精品s色 | 国产美女免费视频 | 成人在线免费观看 | 久久精品影视 | 亚洲成人精品国产 | 欧美久久久久久 | caoporn视频在线 | 天堂资源 | h片免费看| 老司机免费视频 | 国产一级在线观看 | 91大神在线资源观看无广告 | 国产精品国产三级国产aⅴ原创 | 久久亚洲天堂 | 亚洲欧洲精品成人久久奇米网 | 国产成人99久久亚洲综合精品 | 无码一区二区三区视频 | 久久蜜桃av一区二区天堂 | a在线视频观看 | 欧美日本韩国一区二区 | 免费成人高清 | 精品三区| 一区二区免费在线观看 | 国产女人精品视频 | 嫩呦国产一区二区三区av | 日韩在线观看网站 | 国产乱xxav | 99成人|