centos添加代理伺服器
A. centos6.3 怎麼搭建代理服務
實驗環境:
系統 centos6.3
內網 eth0:192.168.223.163
外網 eth1:192.168.22.78
Squid Cache: Version squid-3.1.10
網卡配置如下:
內網:
centos6.3(x64) squid透明代理伺服器(詳細安裝步驟) - Only - Only
外網:
centos6.3(x64) squid透明代理伺服器(詳細安裝步驟) - Only - Only
安裝
[root@only ~]# yum -y install squid
Installing : 7:squid-3.1.10-18.el6_4.x86_64
Verifying : 7:squid-3.1.10-18.el6_4.x86_64
Installed:
squid.x86_64 7:3.1.10-18.el6_4
Complete!
配置文件如下(更改地方用紅色)
[root@only ~]# vim /etc/squid/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/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # 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 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 worktime time 8:00-23:59 //定義工作時間
#acl worktime time 00:00-5:59
#http_access allow mynetwork !worktime //只允許非工作時間上網
#
# 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
# And finally deny all other access to this proxy
http_access allow all
# Squid normally listens to port 3128
http_port 192.168.223.163:3128 transparent
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 2000 16 256
# Leave coremps in the first cache dir
coremp_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
visible_hostname 192.168.223.163
cache_mem 256 MB //squid伺服器佔用內存大小
forwarded_for off //不傳遞被代理地址
via off //不傳遞代理伺服器信息
初始化squid代理伺服器
[root@only ~]# squid -z
2013/08/14 10:06:24| Creating Swap Directories
2013/08/14 10:06:24| /var/spool/squid exists
2013/08/14 10:06:24| Making directories in /var/spool/squid/00
2013/08/14 10:06:24| Making directories in /var/spool/squid/01
2013/08/14 10:06:24| Making directories in /var/spool/squid/02
2013/08/14 10:06:24| Making directories in /var/spool/squid/03
2013/08/14 10:06:24| Making directories in /var/spool/squid/04
2013/08/14 10:06:24| Making directories in /var/spool/squid/05
2013/08/14 10:06:24| Making directories in /var/spool/squid/06
2013/08/14 10:06:24| Making directories in /var/spool/squid/07
2013/08/14 10:06:24| Making directories in /var/spool/squid/08
2013/08/14 10:06:24| Making directories in /var/spool/squid/09
2013/08/14 10:06:24| Making directories in /var/spool/squid/0A
2013/08/14 10:06:24| Making directories in /var/spool/squid/0B
2013/08/14 10:06:24| Making directories in /var/spool/squid/0C
2013/08/14 10:06:24| Making directories in /var/spool/squid/0D
2013/08/14 10:06:24| Making directories in /var/spool/squid/0E
2013/08/14 10:06:24| Making directories in /var/spool/squid/0F
開啟路由功能,並將下面的命令寫入/etc/rc.d/rc.local 文件,使其開機自動開啟路由功能
[root@only ~]# echo '1'>/proc/sys/net/ipv4/ip_forward
或者如下 vi /etc/sysctl.conf文件 將 net.ipv4.ip_forward = 0 改成 =1
[root@only ~]# sysctl -p
net.ipv4.ip_forward = 1
配置iptables防火牆
自動將http請求轉發到代理伺服器上
[root@only ~]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 3128
設置源地址映射
[root@only ~]# iptables -t nat -A POSTROUTING -j SNAT --to-source 192.168.22.78
[root@only ~]# iptables -P INPUT ACCEPT
啟動squid代理服務
[root@only ~]# service squid restart
Stopping squid: [FAILED]
Starting squid: . [ OK ]
查看squid代理伺服器緩存日誌
[root@only ~]# tail -f /var/log/squid/access.log
將squid加入開機啟動項
[root@only ~]# chkconfig squid --level 235 on
搞定。
B. http 代理 在Centos系統里怎樣設置
首先點擊左上方抄-系統襲
點擊--首選項
在首選項找到--網路代理
接著在彈出網路代理首選項,點擊--手動配置代理伺服器
在HTTP代理 輸入IP地址 66.35.68.145為例子
接著設置埠:7808為例
然後點關閉,到這里HTTP也就設完了,那麼HTTP是否設置成功了呢?
接著往下看
打開系統下自帶的瀏覽器
在瀏覽器地址欄里輸入網路地址
在網路框框里輸入IP並網路一下
這里提示本機IP 66.35.68.145就是我們剛剛設置的IP地址
C. centos7怎麼通過代理上網
1.打開/etc/yum.conf 配置文件進行編輯
在後面添加以下內容(ip號+埠後無認證連接)
proxy=http://192.168.5.100:8086
如果需要認證連接則輸入以下內容
proxy=http://192.168.5.100:8086
proxy_username=代理伺服器用戶名
proxy_password=代理伺服器密碼
D. Linux 用作代理伺服器,如何增加允許代理的IP
route add default gw 10.0.0.1
這里的IP地址是你伺服器需要連接的IP地址。
E. centos 7怎麼配置代理伺服器
1.全局的代理設置:
vi /etc/profile
添加下面內容
http_proxy = http://username:password@yourproxy:8080/
ftp_proxy = http://username:password@yourproxy:8080/
export http_proxy
export ftp_proxy
2.yum的代理設置:
vi /etc/yum.conf
F. centos7操作系統下如果把本機作為代理伺服器
已經有很成熟的經驗centos7操作系統下把本機作為代理伺服器,希望對你有幫助:
http://jingyan..com/article/a24b33cd51f0b619ff002b7e.html
其實主要還是如下操作:
1.全局的代理設置:
vi /etc/profile
添加下面內容
http_proxy = http://username:password@yourproxy:8080/
ftp_proxy = http://username:password@yourproxy:8080/
export http_proxy
export ftp_proxy
2.yum的代理設置:
vi /etc/yum.conf
G. 如何安裝centos代理伺服器
CentOS-6.3-i386-bin-DVD1.iso這個就可以的。 下載好以後,在虛擬機中將光碟機設為這個iso文件,就可以開始安裝了。
H. CentOS中如何設置系統級代理
首先點擊左上方-系統抄
http 代理 在Centos系統里怎樣設置
點擊--首選項
http 代理 在Centos系統里怎樣設置
在首選項找到--網路代理
http 代理 在Centos系統里怎樣設置
接著在彈出網路代理首選項,點擊--手動配置代理伺服器
http 代理 在Centos系統里怎樣設置
在HTTP代理 輸入IP地址 66.35.68.145為例子
http 代理 在Centos系統里怎樣設置步驟閱讀
6
接著設置埠:7808為例
http 代理 在Centos系統里怎樣設置