Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and configuration of Linux Squid proxy server under CentOS6.7

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the installation and configuration of Linux Squid proxy server under CentOS6.7". The explanation in this article is simple and clear, and is easy to learn and understand. Please follow the editor's train of thought to study and learn "the installation and configuration of Linux Squid proxy server under CentOS6.7".

Agent Internet software:

Windows SYGATE

Centos squid 3128

Ubuntu shadowsocks

Client settings:

Add http agent to .bashrc

Export http_proxy= http://yourproxyaddress:proxyport

Export https_proxy= http://yourproxyaddress:proxyport

Wget-- no-check-certificate-O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh

Bsp is a multi-user and traffic limit management tool of shadowsocks, which can be managed with simple commands.

CentOS6.7 Linux Squid proxy server installation configuration

Http://balich.blog.51cto.com/6641781/1710760

CentOS6.7 Squid proxy server installation configuration

Squid cache (Squid for short) is a popular proxy server and Web cache server for free software (GNU General Public license). Squid has a wide range of uses, from the front-end cache server as a web server to cache related requests to increase the speed of the Web server, to cache the World wide Web for a group of people to share network resources, domain name system and other web searches, to help network security by filtering traffic, to surfing the Internet through proxies in the local area network. Compared with other agent software under Linux, such as Apache, Socks, TIS FWTK and delegate, Squid is easy to download and install, simple and flexible to configure, and supports caching and multiple protocols. The reason why Squid is widely used is because of its cache function. Squid cache can not only save valuable bandwidth resources, but also greatly reduce the Imax O. From an economic point of view, it is an indispensable role in the architecture of many websites.

Squid can be used not only as a forward proxy but also as a reverse proxy.

Forward agent, Squid is followed by the client, the client wants to access the Internet no matter what the network has to go through Squid. When a user (client) wants to request a home page, it sends an application to Squid, asking Squid to request for it, then Squid connects to the website that the user wants to request and requests the home page, and then sends the home page to the user while keeping a backup. When other users request the same page, Squid immediately sends the saved backup to the user, which makes the user feel quite fast.

Forward proxy, the client needs to make some settings in order to achieve, that is, we usually set the proxy in the IE option. The reverse proxy is that Squid is followed by the server of a site. When the client requests the site, it will first send the request to the Squid, and then Squid will process the user's request action.

How to distinguish:

Forward agent, Squid is followed by the client, the client has to go to the Internet through Squid, for use, is aware of the existence of an agent, commonly used in enterprises, as an agent to access the Internet, can well control the back of the client to access the website

Reverse proxy, Squid is followed by the server, the server to return data to the user needs to go Squid, for the user, do not know that the access is an agent, but feel that the server itself.

Official address: http://www.squid-cache.org/

Reference document: http://www.squid-cache.org/Doc/config/

System environment:

Operating system: CentOS 6.7

Squid version: 3.1.23

Hostname:balichvm.org

1), installation

[root@balichvm ~] # yum install squid-y

2), Squid configuration forward proxy, default configuration file / etc/squid/squid.conf

(1) Edit / etc/squid/squid.conf and modify the following parameters

Add visible_hostname balichvm.org

# cache_dir ufs / var/spool/squid 10016 256 # # remove the preceding #

Format: name; file format; cache directory path; cache size, number of first-level subdirectories in MB;; number of second-level subdirectories

Cache_dir ufs / var/spool/squid 100 16 256

Add cache_men. There is no such configuration by default. Add it manually. Since the cache is slow to be stored on the hard disk, it can be stored in memory.

Cache_mem 64 MB

Under the refresh_pattern, add the files we need to cache, such as pictures, audio and video.

Refresh_pattern\. (jpg | png | gif | mp3 | xml | js | css) 1440 20% 2880 ignore-reload

After saving the configuration file, use the squid-kcheck command to check that the syntax is correct.

(2) start squid

[root@balichvm ~] # / etc/init.d/squid start

Starting squid:. [OK]

[root@balichvm ~] #

The cached directory is generated at / var/spool/squid.

(3)。 test. Squid listens to port 3128 by default (if iptables is used, it needs to be released, or turned off. )

[root@balichOS] # curl-x192.168.171.51:3128-I www.baidu.com

HTTP/1.0 200 OK

Date: Fri, 06 Nov 2015 14:22:23 GMT

Content-Type: text/html; charset=utf-8

Vary: Accept-Encoding

Set-Cookie:BAIDUID=CA2C3DE3C2832FD456EA94D7B71041E5:FG=1; expires=Thu, 31-Dec-37 23 max-age=2147483647; path=/; domain=.baidu.com 55 GMT

Set-Cookie:BIDUPSID=CA2C3DE3C2832FD456EA94D7B71041E5; expires=Thu, 31-Dec-37 23:55:55 GMT;max-age=2147483647; path=/; domain=.baidu.com

Set-Cookie: PSTM=1446819743; expires=Thu,31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com

Set-Cookie: BDSVRTM=0; path=/

Set-Cookie: BD_HOME=0; path=/

Set-Cookie:H_PS_PSSID=10299_17764_17898_1433_7477_17620_17900_17782_17001_17072_15769_12054;path=/; domain=.baidu.com

P3P: CP= "OTI DSP COR IVA OUR IND COM"

Cache-Control: private

Cxy_all:baidu+75e6e8b83b863a1d9ff7d7c75a6c2d38

Expires: Fri, 06 Nov 2015 14:22:19 GMT

X-Powered-By: HPHP

Server: BWS/1.1

X-UA-Compatible: IE=Edge,chrome=1

BDPAGETYPE: 1

BDQID: 0xd402ae2e0002376f

BDUSERID: 0

X-Cache: MISS from balichvm.org

X-Cache-Lookup: MISS from balichvm.org:3128

Via: 1.0 balichvm.org (squid/3.1.23)

Connection: keep-alive

This is equivalent to a proxy server, which is provided to the back clients to surf the Internet, which is mostly used in enterprises.

If you only have open access to those websites, you need to use access control

(4)。 Access control (acl)

Add the following configuration under acl CONNECT method CONNECT

Acl http proto HTTP # specifies which protocol to use

Acl good_domain dstdomain .baidu.com .qq.com # defines the domain name for remote access

Http_access allow good_domain # allowed

Http_access deny! good_domain

After saving the configuration file and reloading the configuration file, you can use this command: squid reconfigure

To test on windows, you need to change the gateway of ip to the IP address of the squid server.

3) configure reverse proxy

Reverse proxy can reduce the pressure on the back-end server, and at the same time, it can give users faster response speed, from the user's point of view, it is like the real access to the back-end machine. Therefore, on the configuration file, the port that squid listens on first needs to be changed from 3128 to 80.

For example, if we do an one-way agent for Baidu, the configuration file is modified as follows:

Http_port 3128 changed to http_port80 accel vhost vport

Add the following:

Cache_peer 61.135.169.125 parent 80 0originserver name=baidu

Cache_peer_domain baidu www.baidu.com

Save configuration file and restart service

[root@balichvm ~] # / etc/init.d/squidrestart

Stop squid:. [OK]

Starting squid:. [OK]

[root@balichvm ~] #

To test on Windows, you need to modify the hosts file and point the www.baidu.com to our squid server IP.

Setting up system-level agents in CentOS

YUM proxy Settings

Edit / etc/yum.conf, add at the end

# Proxy

Proxy= http://username:password@proxy_ip:port/

You can also use proxy_username and proxy_password to configure the username and password of the agent

After this configuration is completed, all users will use an agent when using yum, which can be said to be a global agent.

If you need to configure an agent for an individual user, you can set it in the user's ~ / .bash_profile.

Proxy settings for Wget

Edit / etc/wgetrc, add at the end

# Proxy

Http_proxy= http://username:password@proxy_ip:port/

Ftp_proxy= http://username:password@proxy_ip:port/

System global agent

If you need to set a system-level agent for a user, you can set it in ~ / .bash_profile:

Http_proxy= "http://username:password@proxy_ip:port"

Export_http_proxy

The above settings only work for a certain user, and if you want to work for all system users, you can write them in / etc/profile.

Thank you for reading, the above is the content of "installation and configuration of Linux Squid proxy server under CentOS6.7". After the study of this article, I believe you have a deeper understanding of the installation and configuration of Linux Squid proxy server under CentOS6.7, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report