In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Blog outline
I. Overview of Squid services
II. Installation and operation control
I. Overview of Squid services
As a proxy service software in the application layer, Squid mainly provides the functions of cache acceleration and filtering control in the application layer.
1. The working mechanism of the agent
When a client requests a Web page through a proxy, the designated proxy server will first check its own cache, and if there is already a page in the cache that the client needs, it will directly feedback the page content in the cache to the client. If there is no page to be accessed by the client in the cache, the proxy server sends an access request to Internet. After obtaining the returned Web page, the web page data is saved in the cache and sent to the client, as shown in the following figure:
Because the client's web access request is actually completed by the squid proxy server, it can hide the real IP address of the user and play a certain role of protection. On the other hand, squid can also filter and control the target to be accessed, the address of the client, and the time period of access.
2. Basic types of agents
Traditional proxy: that is, the ordinary proxy service, requires our client to set the address and port of the proxy server in some programs such as browsers, chat tools, and so on, before we can use the proxy to access the network, this way is more troublesome, because the client also needs to specify the proxy server manually, so it is generally used in the Internet environment.
Transparent proxy: the function is the same as the traditional proxy, except that the client does not need to specify the address and port of the proxy server manually, but redirects web access through default routing and firewall policy, which is actually still handled by the proxy server. The process of redirection is entirely carried out by the squid server, so the client does not even know that he is using the squid proxy service, so? We call it transparent mode.
Transparent proxy is mostly used in LAN environment, for example, after enabling transparent proxy in Linux gateway, LAN hosts can enjoy better Internet speed without additional settings.
II. Installation and operation control
Required equipment:
One Windows client; IP address: 192.168.100.102linux client; IP address: 192.168.100.10squid server; IP address: 192.168.100.20web server; IP address: 192.168.100.30
For the required image, please visit: https://pan.baidu.com/s/1-3jN_z-JqWg2X1Bpz0SHUw
Extraction code: ysxn
1. Install httpd [centos03 @ root] # yum-y install httpd [root@centos03 ~] # cd / var/www/html/ [root@centos03 html] # ls-a. .. [root@centos03 html] # echo "www.accp.com" > index.html [root@centos03 ~] # systemctl start httpd [root@centos03 ~] # systemctl enable httpd 2, install linux command line client [root@centos01 ~] # yum-y install elinks [root@centos01 ~] # elinks http://192.168.100.30
3 、 Compile and install Squid [root @ centos02 ~] # mount / dev/cdrom / mnt/ [root@centos02 ~] # tar zxvf / mnt/squid-3.4.6.tar.gz-C / usr/src/ [root@centos02 squid-3.4.6] #. / configure-- prefix=/usr/local/squid-- sysconfdir=/etc-- enable-linux-netfilter-- enable-async-io=240-- enable-default-err-language-Simplify_Chinese-- disable-poll -enable-epoll-enable-gnuregex [root@centos02 squid-3.4.6] # make & & make install
The specific functions of the above configuration items are as follows:
-- prefix=/usr/local/squid: specify the installation directory;-- sysconfdir=/etc: modify the configuration file to another directory separately;-- enable-linux-netfilter: use kernel filtering;-- enable-async-io= value: asynchronous Iripo to improve storage performance;-- enable-default-err-language=Simplify_Chinese: error message display language;-- disable-poll and-- enable-epoll: turn off poll mode by default, turn on epoll mode to improve performance -- enable-gunregex: use GUN regular expressions
For more configuration items, please refer to ". / configure-- help"
After the installation is complete, create linked files, users, and groups
[root@centos02] # ln-s / usr/local/squid/sbin/* / usr/local/sbin/ [root@centos02 ~] # useradd-M-s / sbin/nologin squid [root@centos02 ~] # chown-R squid:squid / usr/local/squid/var/
4. Modify the squid main configuration file
[root@centos02 ~] # vim / etc/squid.conf 54 http_access allow all 60 http_port 3128 61 cache_effective_user squid 62 cache_effective_group squid 63 reply_body_max_size 10 MB 68 coredump_dir / usr/local/squid/var/cache/squid [root@centos02] # squid-k parse 5, Create a squid management service script [root@centos02 ~] # vim / etc/init.d/squid #! / bin/bash# chkconfig: 35902managers config file:/etc/squid.conf# pidfile: / usr/local/squid/var/run/squid.pid# Description: Squid-Internet object cache.PID= "/ usr/local/squid/var/run/squid.pid" CONF= "/ etc/squid.conf" CMD= "/ usr/local/squid/sbin/squid" case "$1" in Start) netstat-anpt | grep squid & > / dev/null if [$?-eq 0] then echo "squid is running" else echo "starting squid..." $CMD fi ; stop) $CMD-k kill & > / dev/null rm-rf $PID & > / dev/null echo "closing squid...";; status) [- f $PID] & > / dev/null if [$?-eq 0] then netstat-anpt | grep squid else echo "Squid is not running." Fi;; restart) $0 stop & > / dev/null echo "shutting down squid..." $0 start & > / dev/null echo "starting squid...";; reload) $CMD-k reconfigure;;check) $CMD-k parse;;*) echo "usage: $0 {start | stop | restart | reload | check | status}" exit 1 Esac [root@centos02 ~] # chmod + x / etc/init.d/squid [root@centos02 ~] # chkconfig-- add squid [root@centos02 ~] # chkconfig-- level 35 squid on [root@centos02] # / etc/init.d/squid start is starting squid...
Now the squid proxy server based on traditional proxy has been configured.
6. Linux client command line uses proxy server [root@centos01 ~] # vim / etc/profileHTTP_PROXY= http://192.168.100.20:3128 HTTPS_PROXY= http://192.168.100.20:3128 FTP_PROXY= http://192.168.100.20:3128 NO_PROXY=192.168.10.,192.168.20. Export HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY [root@centos01 ~] # source / etc/profile [root@centos01 ~] # elinks http://192.168.100.30 [root@centos03 ~] # tail-f / var/log/httpd/access_log 192.168.100.20-[ 18/Nov/2019:04:38:40 + 0800] "GET / HTTP/1.1" 200 13 "-" ELinks/0.12pre6 (textmode) Linux; 80x18-2) 7. The Windows client uses the proxy server 1) the network card is replaced with the same network card
2) configure the IP address of the same network segment
3) configure proxy server IP address and port number
4) whether the test is successful by visiting 192.168.100.30
5) the website server tracks the access log file of the squid proxy server [root@centos03 ~] # tail-f / var/log/httpd/access_log 192.168.100.20-[18/Nov/2019:04:38:40 + 0800] "GET / HTTP/1.1" 200 13 "-" ELinks/0.12pre6 (textmode; Linux) 80x18-2) "192.168.100.20-[18/Nov/2019:05:18:03 + 0800]" GET / favicon.ico HTTP/1.1 "404209"-"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
Transparent agent will be configured in detail in the next blog post, look forward to it!
-this is the end of this article. Thank you for reading-
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.