在Azure上部署squid的教程

来源:互联网 发布:废旧金属行情软件 编辑:程序博客网 时间:2024/05/22 02:03

CentOS部署

首先关闭防火墙:

setenforce 0

设置最大文件数:

ulimit -n 1048576

设置最大文件句柄数:

echo "* soft nofile 1048576" >> /etc/security/limits.confecho "* hard nofile 1048576" >> /etc/security/limits.conf

停止sendmail服务,防止占用25 SMTP端口:

killall sendmail

停止postfix服务,防止占用25 SMTP端口:

/etc/init.d/postfix stop

从Linux运行级关闭postfix服务:

chkconfig --level 2345 postfix off

安装squid:

这里必须用25端口, 别问为什么。。。

yum -y install squid

vim /etc/squid/squid.conf,写入以下内容:

acl manager proto cache_objectacl localhost dst 127.0.0.0/8 0.0.0.0/32 ::1acl SSL_ports port 443acl Safe_ports port 80      # httpacl Safe_ports port 21      # ftpacl Safe_ports port 443     # httpsacl Safe_ports port 70      # gopheracl Safe_ports port 210     # waisacl Safe_ports port 1025-65535  # unregistered portsacl Safe_ports port 280     # http-mgmtacl Safe_ports port 488     # gss-httpacl Safe_ports port 591     # filemakeracl Safe_ports port 777     # multiling httpacl CONNECT method CONNECThttp_access allow manager localhosthttp_access deny managerhttp_access deny !Safe_portshttp_access deny CONNECT !SSL_portshttp_access allow all http_port 25coredump_dir /var/spool/squidrefresh_pattern ^ftp:       1440    20% 10080refresh_pattern ^gopher:    1440    0%  1440refresh_pattern -i (/cgi-bin/|\?) 0 0%  0refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880refresh_pattern .       0   20% 4320strip_query_terms off

重启squid:

/etc/init.d/squid restart

检查端口是否开启

netstat -ntpl |grep squid

从Linux运行级开启squid服务:

chkconfig --level 2345 squid on

至此,你的服务器就已经部署成了代理服务器。(参考自这里)

加入用户验证

yum install -y openssl openssl-devel httpd

passwd 文件使用 htpasswd 生成,auth_user 替换为自己需要设定的用户名

htpasswd -c /etc/squid/passwd auth_user

vim /etc/squid/squid.conf,写入以下内容:

auth解释:
第一行:选择的认证方式为basic,认证程序路径和密码文件路径。
第二行:认证程序的进程数
第三行:认证有效时间
第四行:认证领域内容,上面定义的web浏览需要输入用户密码
第五,六行:设置允许认证的用户访问

# authauth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwdauth_param basic children 5auth_param basic credentialsttl 2 hoursauth_param basic realm Example.com's Squid proxy-cachingacl auth_user proxy_auth REQUIREDhttp_access allow auth_user# And finally deny all other access to this proxyhttp_access deny all# Squid normally listens to port 3128http_port 25

使用HTTPS

如果要使用https协议则必须找台国内VPS或者自己本机安装Stunnel ,并修改以下配置:

https_port 443 cert=/etc/squid/xx.crt key=/etc/squid/xx.key

上面的密钥文件使用下面的命令来生成
(需要注意的是,Common Name需要与服务器的IP或者主机名一致)

cd /etc/squidopenssl req -new > hb.csropenssl rsa -in privkey.pem -out xx.keyopenssl x509 -in xx.csr -out xx.crt -req -signkey xx.key -days 3650

参考自这里

服务器安装stunnel - linux

yum install -y stunnel 安装killall stunnel 停止stunnel 运行

增加文件/etc/stunnel/tunnel.conf ,配置如下:

[proxy]client = no[squid]accept = 其他端口connect = 127.0.0.1:25cert = /etc/stunnel/stunnel.pem

stunnel.pem生成方法可参考这里

本地安装stunnel -Windows

下载:https://www.stunnel.org/downloads.html
修改关键配置如下:

[proxy]client = yesaccept = 本地:端口connect = 远程:端口

可能用得找的东西 XXXList

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 龙肝泻胆丸适用什么人 哪些人不适合吃消遥丸 哪些人不宜使用香砂和胃丸 哪些人不适合用木香顺气丸 补脾益肠丸不适合什么人吃 龙胆泄肝丸不适用那些人 什么人不能吃五子洐宗丸 大活络丸哪些人不能吃 骨化三醇胶丸适合适合什么人 什么人不宜吃麝香保心丸 天王补心丸不适合什么人吃 人参保肺丸 香砂养胃丸不适合什么人吃 香砂六君子丸不适合哪些人 补脾益肠丸适合什么人吃 藿香正气丸什么人不能吃 安神补心丸适合哪些人吃 什么人不适合吃柏子养心丸 木香顺气丸不适合哪些人吃 泰国蜈蚣丸哪些人禁用 小活络丸哪些人不能用 2陈丸哪种人不能吃 大补阴丸适合什么人吃 黑芝麻丸不适合什么人吃 清心丸适合什么人吃 安宫丸什么人不能吃 兰丸多人上受 舒肝健胃丸不适合什么人吃 丹栀逍遥丸适合哪些人 人丹 什么人不适合吃红毛丹 哪些人不适合吃香丹清 丹叁粉哪种人不能吃 丹栀逍遥丸什么人不能吃 百消丹不适用于什么人 哪些人不能吃摩罗丹 环阳丹医生江涛是何许人 丹人修仙之仙界篇 全家人的丹尼斯供应商 全家人的丹尼斯大卖场供应商 艳鼎丹仙 那时那人