搭建 CentOS 6 服务器(12) - squid、Varnish
程序员文章站
2022-06-12 15:32:12
...
(一)squid
安装
设置
启动服务
(二)Varnish
安装
设置
启动服务
确认
安装
# yum -y install epel-release # yum -y install squid
设置
# cp /etc/squid/squid.conf /etc/squid/squid.conf.bak -Allow IP Address # vi /etc/squid/squid.conf acl localnet src 192.168.21.0/24 -Changing Squid Port(Default 3128) # vi /etc/squid/squid.conf http_port 5000 -Allow a Specific Port # vi /etc/squid/squid.conf acl Safe_ports port 5432 -Blocking Websites # vi /etc/squid/blocked_sites baidu.com # vi /etc/squid/squid.conf acl blocked_sites dstdomain "/etc/squid/blocked_sites" http_access deny blocked_sites -Using Basic Authentication # yum -y install httpd-tools # touch /etc/squid/passwd && chown squid /etc/squid/passwd # htpasswd /etc/squid/passwd pxuser # vi /etc/squid/squid.conf auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd auth_param basic children 5 auth_param basic realm Squid Basic Authentication auth_param basic credentialsttl 2 hours acl auth_users proxy_auth REQUIRED http_access allow auth_users -Hide proxy # vi /etc/squid/squid.conf forwarded_for off request_header_access Referer deny all request_header_access X-Forwarded-For deny all request_header_access Via deny all request_header_access Cache-Control deny all
启动服务
# /etc/init.d/squid start # squid -v Squid Cache: Version 3.5.20 Service Name: squid
# tail -f /var/log/squid/access.log
(二)Varnish
安装
# rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm # yum install -y varnish # varnishd -V
设置
# vi /etc/sysconfig/varnish VARNISH_LISTEN_PORT=6081 # vi /etc/varnish/default.vcl backend default { .host = "127.0.0.1"; .port = "81"; } # varnishd -C -f /etc/varnish/default.vcl
启动服务
# service varnish start # service varnishncsa start # service varnishlog start
确认
# varnishadm backend.list
推荐阅读
-
VPS CentOS-6 下 LNMP HTTP web服务器的搭建步骤
-
搭建 CentOS 6 服务器(3) - 初始环境设置
-
搭建 CentOS 6 服务器(10) - Samba
-
搭建 CentOS 6 服务器(6) - MySQL、PostgreSQL
-
搭建 CentOS 6 服务器(14) - CVS、SVN、Git
-
搭建 CentOS 6 服务器(4) - TigerVNC
-
搭建 CentOS 6 服务器(13) - Keepalived、HAProxy、LVS
-
搭建 CentOS 6 服务器(5) - Java(Ant/Maven/Gradle)、PHP(php-fpm)
-
搭建 CentOS 6 服务器(8) - Apache/Nginx/Jetty、Tomcat、WildFly
-
搭建 CentOS 6 服务器(11) - rsync、Amanda