Merge pull request #1635 from ZTinoZ/master

Finish the translation by ZTinoZ
This commit is contained in:
Xingyu.Wang 2014-09-17 11:31:51 +08:00
commit 3c04b931e4
2 changed files with 131 additions and 132 deletions

View File

@ -1,132 +0,0 @@
Translating by ZTinoZ
10 Useful “Squid Proxy Server” Interview Questions and Answers in Linux
================================================================================
Its not only to System Administrator and Network Administrator, who listens the phrase Proxy Server every now and then but we too. Proxy Server is now a corporate culture and is the need of the hour. Proxy server now a days is implemented from small schools, cafeteria to large MNCs. Squid (also known as proxy) is such an application which acts as proxy server and one of the most widely used tool of its kind.
This Interview article aims at strengthening your base from Interview point on the ground of proxy server and squid.
![Squid Interview Questions](http://www.tecmint.com/wp-content/uploads/2014/07/Squid-Interview-Questions.png)
Squid Interview Questions
### 1. What do you mean by Proxy Server? What is the use of Proxy Server in Computer Networks? ###
> **Answer** : A Proxy Server refers to physical machine or Application which acts intermediate between client and resource provider or server. A client seeks for file, page or data from the the proxy server and proxy server manages to get the requested demand of client fulfilled by handling all the complexities in between.
Proxy servers are the backbone of WWW (World Wide Web). Most of the proxies of today are web proxies. A proxy server handles the complexity in between the Communication of client and Server. Moreover it provides anonymity on the web which simply means your identity and digital footprints are safe. Proxies can be configured to allow which sites client can see and which sites are blocked.
### 2. What is Squid? ###
> **Answer** : Squid is an Application software released under GNU/GPL which acts as a proxy server as well as web cache Daemon. Squid primarily supports Protocol like HTTP and FTP however other protocols like HTTPS, SSL,TLS, etc are well supported. The feature web cache Daemon makes web surfing faster by caching web and DNS for frequently visited websites. Squid is known to support all major platforms including Linux, UNIX, Microsoft Windows and Mac.
### 3. What is the default port of squid and how to change its operating port? ###
> **Answer** : The default port on which squid runs is 3128. We can change the operating port of squid from default to any custom unused port by editing its configuration file which is located at /etc/squid/squid.conf as suggested below.
Open /etc/squid/squid.conf file and with your choice of editor.
# nano /etc/squid/squid.conf
Now change this port to any other unused port. Save the editor and exit.
http_port 3128
Restart the squid service as shown below.
# service squid restart
### 4. You works for a company the management of which ask you to block certain domains through squid proxy server. What are you going to do? ###
> **Answer** : Blocking domain is a module which is implemented well in the configuration file. We just need to perform a little manual configuration as suggested below.
a. Create a file say blacklist under directory /etc/squid.
# touch /etc/squid/blacklist
b. Open the file /etc/squid/blacklist with nano editor.
# nano /etc/squid/blacklist
c. Add all the domains to the file blacklist with one domain per line.
.facebook.com
.twitter.com
.gmail.com
.yahoo.com
...
d. Save the file and exit. Now open the Squid configuration file from location /etc/squid/squid.conf.
# nano /etc/squid/squid.conf
e. Add the lines below to the Squid configuration file.
acl BLACKLIST dstdom_regex -i “/etc/squid/blacklist”
http_access deny blacklist
f. Save the configuration file and exit. Restart Squid service to make the changes effective.
# service squid restart
### 5. What is Media Range Limitation and partial download in Squid? ###
> **Answer** : Media Range Limitation is a special feature of squid in which just the required data is requested from the server and not the whole file. This feature is very well implemented in various videos streaming websites like Youtube and Metacafe where a user can click on the middle of progress bar hence whole video need not be fetched except for the requested part.
The squids feature of partial download is implemented well within windows update where downloads are requested in the form of small packets which can be paused. Because of this feature a update downloading windows machine can be restarted without any fear of data loss. Squid makes the Media Range Limitation and Partial Download possible only after storing a copy of whole data in it. Moreover the partial download gets deleted and not cached when user points to another page until Squid is specially configured somehow.
### 6. What is reverse proxy in squid? ###
> **Answer** : Reverse proxy is a feature of Squid which is used to accelerate the web surfing for end user. Say the Real server RS contains the resource and PS is the proxy Server. The client seek some data which is available at RS. It will rely on RS for the specified data for the first time and the copy of that specified data gets stored on PS for configurable amount of time. For every request for that data from now PS becomes the real source. This results in Less traffic, Lesser CPU usages, Lesser web resource utilization and hence lesser load to actual server RS. But RS has no statistics for the total traffic since PS acted as actual server and no Client reached RS. X-Forwarded-For HTTP can be used to log the client IP although on RS.
Technically it is feasible to use single squid server to act both as normal proxy server and reverse proxy server at the same point of time.
### 7. Since Squid can be used as web-cache Daemon, is it possible to Clear its Cache? How? ###
> **Answer** : No Doubt! Squid acts as web-cache Daemon which is used to accelerate web surfing still it is possible to clear its cache and that too very easily.
a. First stop Squid proxy server and delete cache from the location /var/lib/squid/cache directory.
# service squid stop
# rm -rf /var/lib/squid/cache/*<
b. Create Swap directories.
# squid -z
### 8. A client approaches you, who is working. They want the web access time be restricted for their children. How will you achieve this scenario? ###
Say the web access allow time be 4o clock to 7o clock in the evening for three hours, sharply form Monday to Friday.
a. To restrict web access between 4 to 7 from Monday to Friday, open the Squid configuration file.
# nano /etc/squid/squid.conf
b. Add the following lines and save the file and exit.
acl ALLOW_TIME time M T W H F 16:00-19:00
shttp_access allow ALLOW_TIME
c. Restart the Squid Service.
# service squid restart
### 9. Squid stores data in which file format? ###
> **Answer** : Data stored by Squid is in ufs format. Ufs is the old well-known Squid storage format.
### 10. Where do cache gets stored by squid? ###
> **Answer** : A squid stores cache in special folder at the location /var/spool/squid.
Thats all for now. Ill be here again with another interesting article soon. Till then stay tuned and connected to Tecmint. Dont forget to provide us with your valuable feedback the comment section below.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/squid-interview-questions/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/

View File

@ -0,0 +1,131 @@
10个实用的关于linux中Squid代理服务器的面试问答
================================================================================
不仅是系统管理员和网络管理员时不时会听到“代理服务器”这个词我们也经常听到。代理服务器已经是一种企业的文化而且那是需要时间来积累的。它现在也在一些小型的学校或者大型跨国公司的自助餐厅里得到了实现。Squid也可做代理服务就是这样一个应用程序它既可以被作为代理服务器同时也是在其同类工具中比较被广泛使用的一种。
本文旨在提高你在遇到关于代理服务器面试点时的一些基本应对能力。
![Squid Interview Questions](http://www.tecmint.com/wp-content/uploads/2014/07/Squid-Interview-Questions.png)
以下为面试问答的内容
### 1. 什么是代理服务器?代理服务器在计算机网络中有什么用途? ###
> **回答** : 代理服务器是指那些作为客户端和资源提供商或服务器之间的中间件的物理机或者应用程序。客户端从代理服务器中寻找文件、页面或者是数据而且代理服务器能处理客户端与服务器之间所有复杂事务从而满足客户端的生成的需求。
代理服务器是WWW万维网的支柱它们其中大部分都是Web代理。一台代理服务器能处理客户端与服务器之间的复杂通信事务。此外它在网络上提供的是匿名信息那就意味着你的身份和浏览痕迹都是安全的。代理可以去配置允许哪些网站的客户能看到哪些网站被屏蔽了。
### 2. Squid是什么? ###
> **回答** : Squid是一个在GNU/GPL协议下发布的即可作为代理服务器同时也可作为Web缓存守护进程的应用软件。Squid主要是支持像HTTP和FTP那样的协议但是对其它的协议比如HTTPSSSL,TLS等同样也能支持。其特点是Web缓存守护进程通过从经常上访问的网站里缓存Web和DNS从而让上网速度更快。Squid支持所有的主流平台包括LinuxUNIX微软公司的Windows和苹果公司的Mac。
### 3. Squid的默认端口是什么怎么去修改它的操作端口 ###
> **回答** : Squid运行时的默认端口是3128。我们可以通过编辑它的配置文件来把它的默认端口修改成未被用户使用的端口路径是 /etc/squid/squid.conf ,建议如下。
用你的编辑器打开 /etc/squid/squid.conf 文件。
# nano /etc/squid/squid.conf
现在把它修改成未被使用的其它端口,并保存退出。
http_port 3128
重新启动Squid代理服务如下显示。
# service squid restart
### 4. 你的公司管理层要求你通过Squid代理服务器屏蔽掉一些域名你怎么做 ###
> **回答** : 屏蔽域名是一个在配置文件中实现的功能模块。我们只需要执行一个小的手动配置即可,建议如下。
a. 在 /etc/squid 目录下创建一个名为 blacklist 的文件。
# touch /etc/squid/blacklist
b. 用nano编辑器打开这个文件。
# nano /etc/squid/blacklist
c. 以每行一个域名的方式将想要屏蔽的域名写进这个文件里。
.facebook.com
.twitter.com
.gmail.com
.yahoo.com
...
d. 保存退出,然后从 /etc/squid/squid.conf 打开Squid配置文件。
# nano /etc/squid/squid.conf
e. 在配置文件中添加如下行。
acl BLACKLIST dstdom_regex -i “/etc/squid/blacklist”
http_access deny blacklist
f. 保存配置文件并退出重启Squid服务让其生效。
# service squid restart
### 5. 在Squid中什么是媒体范围限制和部分下载 ###
> **回答** : 媒体范围限制是Squid的一种特殊的功能它只从服务器中获取所需要的数据而不是整个文件。这个功能很好的实现了用户在各种视频流媒体网站如YouTube和Metacafe看视频时可以点击视频中的进度条来选择进度因此整个视频不用全部都加载除了一些需要的部分。
Squid部分下载功能的特点是很好地实现了在Windows更新时下载的文件能以一个个小数据包的形式暂停。正因为它的这个特点正在下载文件的Windows机器能不用担心数据会丢失从而进行恢复下载。Squid让媒体范围限制和部分下载功能只在存储一个完整文件的复件之后实现。此外当用户指向另一个页面时Squid要以某种方式进行特殊地配置部分下载下来的文件才会不被删除且留有缓存。
### 6. 什么是Squid的反向代理 ###
> **回答** : 反向代理是Squid的一个特点这个功能被用来加快最终用户的上网速度。缩写为 RS 的原服务器包含了所有资源,而代理服务器则叫 PS 。客户端寻找RS所提供的数据第一次指定的数据和它的复件会经过多次配置从RS上存储在PS上。这样的话每次从PS上请求的数据就等于就是从原服务器上获取的。这样就会减轻网络拥堵减少CPU使用率降低网络资源的利用率从而缓解原来实际服务器的负载压力。但是RS统计不了总流量的数据因为PS分担了部分原服务器的任务。X-Forwarded-For HTTP 就能记录下通过HTTP代理或负载均衡方式连接到RS的客户端最原始的IP地址。
严格意义上来说用单个Squid服务器同时作为正向代理服务器和反向代理服务器是可行的。
### 7. 由于Squid能作为一个Web缓存守护进程那缓存可以删除吗怎么删除 ###
> **回答** : 当然作为一个Web缓存守护进程Squid能加快网页的访问速度清除缓存也是非常简单的。
a. 首先停止Squid代理服务然后从这个 /var/lib/squid/cache 目录中删除缓存。
# service squid stop
# rm -rf /var/lib/squid/cache/*<
b. 创建交换分区目录。
# squid -z
### 8. 你身边有一台客户机,而你正在工作,如果想要限制儿童的访问时间段,你会怎么去设置那个场景? ###
把允许访问的时间设置成晚上4点到7点三个小时跨度为星期一到星期五。
a. 想要限制Web访问时间在星期一到星期五的晚上4点到7点要先打开Squid的配置文件。
# nano /etc/squid/squid.conf
b. 在配置文件中添加如下行,保存文件并退出。
acl ALLOW_TIME time M T W H F 16:00-19:00
shttp_access allow ALLOW_TIME
c. 重启Squid服务。
# service squid restart
### 9. Squid存储的数据是什么文件格式 ###
> **回答** : Squid存储的数据是UFS文件格式的。UFS是一种老的使用比较广泛的Squid存储格式
### 10. Squid的缓存会存储到哪里 ###
> **回答** : Squid存储的缓存是位于 /var/spool/squid 的特殊目录下。
以上就是全部内容了很快我还会带着其它有趣的内容回到这里届时还请继续关注Tecmint。别忘了告诉我们你的反馈和评论。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/squid-interview-questions/
作者:[Avishek Kumar][a]
译者:[ZTinoZ](https://github.com/ZTinoZ)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/