久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

squid傳統(tǒng)代理和透明代理

緩存代理概述

web代理的工作機(jī)制:
緩存網(wǎng)頁對象,減少重復(fù)請求

squid傳統(tǒng)代理和透明代理

創(chuàng)新互聯(lián)是專業(yè)的晉江網(wǎng)站建設(shè)公司,晉江接單;提供成都做網(wǎng)站、網(wǎng)站制作,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行晉江網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

代理的基本類型

傳統(tǒng)代理:適用于Internet,需明確指定服務(wù)端
透明代理:客戶機(jī)不需要指定代理服務(wù)器的地址和端口,是通過默認(rèn)路由,防火墻將web重定向給代理

使用代理的好處

提高web訪問速度
隱藏客戶機(jī)的真實(shí)IP地址

一,傳統(tǒng)代理

實(shí)驗(yàn)環(huán)境

squid服務(wù)器 192.168.13.179
web服務(wù)器 192.168.13.151
client測試機(jī)192.168.13.135

1,在squid服務(wù)器上安裝squid代理服務(wù)器

[root@squid ~]# mkdir /abc
[root@squid ~]# mount.cifs //192.168.100.3/LNMP-C7 /abc/   ##掛載
[root@squid ~]# cd /abc/
[root@squid abc]# tar zxvf squid-3.4.6.tar.gz -C /opt  ##解壓
[root@squid abc]# yum install gcc gcc-c++ make -y  ##安裝環(huán)境組件
[root@squid abc]# cd /opt/squid-3.4.6
[root@squid squid-3.4.6]# ./configure \
--prefix=/usr/local/squid \  ##安裝路徑
--sysconfdir=/etc \   ##配置文件目錄
--enable-arp-acl \   ##支持acl訪問控制列表
--enable-linux-netfilter \   ##支持網(wǎng)絡(luò)篩選
--enable-linux-tproxy \   ##支持透明
--enable-async-io=100 \   ##io優(yōu)化
--enable-err-language="Simplify_Chinese" \   ##報(bào)錯(cuò)顯示簡體中文
--enable-underscore \
--enable-poll \
--enable-gnuregex   ##支持正則表達(dá)
[root@squid squid-3.4.6]# make && make install   ##編譯安裝
[root@squid squid-3.4.6]# ln -s /usr/local/squid/sbin/* /usr/local/sbin/  ##便于系統(tǒng)識別
[root@squid squid-3.4.6]# useradd -M -s /sbin/nologin squid   ##創(chuàng)建系統(tǒng)用戶
[root@squid squid-3.4.6]# chown -R squid.squid /usr/local/squid/var/  ##給目錄所有文件屬主屬組權(quán)限

2,修改squid配置文件,并優(yōu)化啟動(dòng)項(xiàng)

[root@squid squid-3.4.6]# vim /etc/squid.conf   ##修改squid配置文件
# And finally deny all other access to this proxy
http_access allow all   ##添加此項(xiàng)
#http_access deny all ##注釋,允許終端訪問

# Squid normally listens to port 3128
http_port 3128
cache_effective_user squid   ##指定用戶squid
cache_effective_group squid ##指定組
[root@squid squid-3.4.6]# squid -k parse ##檢查配置文件語法
[root@squid squid-3.4.6]# squid -z  ##初始化緩存目錄
[root@squid squid-3.4.6]# squid  ##開啟服務(wù)
[root@squid squid-3.4.6]# netstat -ntap | grep 3128  ##查看squid端口
[root@squid squid-3.4.6]# cd /etc/init.d/
[root@squid init.d]# vim squid    ##編輯service啟動(dòng)squid的腳本
#!/bin/bash
#chkconfig: 2345 90 25
PID="/usr/local/squid/var/run/squid.pid"   ##PID文件進(jìn)程號
CONF="/etc/squid.conf"   ##主配置文件
CMD="/usr/local/squid/sbin/squid"   ##啟動(dòng)命令

case "$1" in
start)
                netstat -ntap | grep squid &> /dev/null
                if [ $? -eq 0 ]
                then 
                 echo "squid is running"
                 else
                 echo "正在啟動(dòng) squid...." 
                 $CMD
                fi
                ;;
stop)
                $CMD -k kill &> /dev/null   ##關(guān)閉squid
                rm -rf $PID &> /dev/null    ##刪除PID文件
                ;;
status)
                [ -f $PID ] &> /dev/null
                 if [ $? -eq 0 ]
                                then
                                 netstat -ntap | grep squid
                                else
                                 echo "squid is not running"
                fi
                ;;
restart)
                $0 stop &> /dev/null
                echo "正在關(guān)閉 squid..."
                $0 start &> /dev/null
                echo "正在啟動(dòng) squid..."
                ;;
reload)
                $CMD -k reconfigure  ##重載配置文件
                ;;
check)
                $CMD -k parse   ##檢查語法
                ;;
*)
                echo "用法:$0{start|stop|reload|status|check|restart}"
                ;;
esac
[root@squid init.d]# chmod +x squid   ##給執(zhí)行權(quán)限
[root@squid init.d]# chkconfig --add squid   ##添加到service管理中
[root@squid init.d]# chkconfig --level 35 squid on  ##開機(jī)自啟

3,設(shè)置傳統(tǒng)代理配置

[root@squid init.d]# vim /etc/squid.conf  ##修改主配置文件
# Squid normally listens to port 3128
http_port 3128
cache_mem 64 MB   ##內(nèi)存空間大小
reply_body_max_size 10 MB  ##允許下載最大文件大小
maximum_object_size 4096 KB   ##允許保存緩存空間最大對象大小
[root@squid init.d]# service squid restart
[root@squid init.d]# iptables -L  ##查看表內(nèi)容
[root@squid init.d]# iptables -F  ##清空表緩存
[root@squid init.d]# setenforce 0
[root@squid init.d]# iptables -I INPUT -p tcp --dport 3128 -j ACCEPT ##允許3128端口
[root@squid init.d]# service squid reload  ##重載配置文件

4,在web服務(wù)器上安裝http服務(wù)

[root@web ~]# systemctl stop firewalld.service   ##關(guān)閉防火墻
[root@web ~]# setenforce 0
[root@web ~]# yum install httpd -y  ##安裝web服務(wù)
[root@web ~]# systemctl start httpd.service

使用client訪問web網(wǎng)頁

squid傳統(tǒng)代理和透明代理

[root@web ~]# cd /etc/httpd/logs/  ##查看日志文件
[root@web logs]# vim access_log  ##此時(shí)是135地址訪問的

5,修改客戶機(jī)瀏覽器代理設(shè)置

squid傳統(tǒng)代理和透明代理

##重新利用客戶機(jī)訪問web服務(wù)器
[root@web ~]# cd /etc/httpd/logs/  ##查看日志文件
[root@web logs]# vim access_log  ##此時(shí)是179代理服務(wù)器訪問的

二,透明代理

實(shí)驗(yàn)拓?fù)?/h2>

squid傳統(tǒng)代理和透明代理

實(shí)驗(yàn)環(huán)境

squid服務(wù)器 ens33:192.168.13.184
                    ens36:192.168.10.1 (僅主機(jī)模式)
web服務(wù)器 192.168.13.151
client 192.168.10.10  (僅主機(jī)模式)

1,在squid服務(wù)上添加一塊網(wǎng)卡,并設(shè)置ip地址

squid傳統(tǒng)代理和透明代理

[root@squid ~]# cd /etc/sysconfig/network-scripts/
[root@squid network-scripts]# cp -p ifcfg-ens33 ifcfg-ens36
[root@squid network-scripts]# vim ifcfg-ens36  ##修改ens36ip信息
BOOTPROTO=static
##刪除uuid修改33為36
IPADDR=192.168.10.1
NETMASK=255.255.255.0  
[root@squid network-scripts]# service network restart   ##重啟網(wǎng)絡(luò)服務(wù)
[root@squid network-scripts]# vim /etc/sysctl.conf   ##開啟路由轉(zhuǎn)發(fā)
net.ipv4.ip_forward=1
[root@squid network-scripts]# sysctl -p   ##加載

2,在web服務(wù)器上指定靜態(tài)路由

[root@web ~]# route add -net 192.168.10.0/24 gw 192.168.13.184  ##添加靜態(tài)路由

3,在squid服務(wù)器上設(shè)置透明代理

[root@squid network-scripts]# vim /etc/squid.conf   ##設(shè)置配置文件
http_port 192.168.10.1:3128 transparent   ##設(shè)置透明代理
cache_effective_user squid
cache_effective_group squid
[root@squid network-scripts]# service squid stop  ##關(guān)閉開啟squid服務(wù)
[root@squid network-scripts]# service squid start
[root@squid network-scripts]# iptables -F  ##清空表緩存
[root@squid network-scripts]# iptables -t nat -F
[root@squid network-scripts]# iptables -t nat -I PREROUTING -i ens36 -s 192.168.10.0/24 -p tcp --dport 80 -j REDIRECT --to 3128
##定義規(guī)則入口ens36,80端口重定向到3128
[root@squid network-scripts]# iptables -t nat -I PREROUTING -i ens36 -s 192.168.10.0/24 -p tcp --dport 443 -j REDIRECT --to 3128
##https443端口
[root@squid network-scripts]# iptables -I INPUT -p tcp --dport 3128 -j ACCEPT
##允許3128端口訪問

4,用測試機(jī)測試

squid傳統(tǒng)代理和透明代理

5,在web服務(wù)器上查看訪問日志文件

[root@web ~]# cd /var/log/httpd/
[root@web httpd]# vim access_log   ##查看訪問日志信息

squid傳統(tǒng)代理和透明代理

##此時(shí)是184訪問的并不是測試機(jī)的地址訪問的

謝謝閱讀??!

網(wǎng)站標(biāo)題:squid傳統(tǒng)代理和透明代理
路徑分享:http://sd-ha.com/article4/gjjsoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、App設(shè)計(jì)、企業(yè)建站定制開發(fā)Google、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)