Squid can do reverse proxies to cache the relatively static pages in the system and to be responsible for equalization,
Improve website access speed, enhance site availability, security.
The user accesses the IP address of the Squid reverse proxy server so that the client's URL request is sent to the reverse proxy server.
If the requested resource is cached in the Squid reverse proxy server, the requested resource is returned directly to the client.
Otherwise, the reverse proxy server requests the resource from the backend Web server and then returns the requested answer to the client.
The answer is also cached locally for use by the next requestor.
It is as follows:
Install squid steps in Windows:
1. Download the installation files for squid windows from http://squid.acmeconsulting.it.
You can also download it from http://download.csdn.net/detail/kkdelta/4474605.
Download and unzip the squid in the C \ Directory (default), you can also put squid to other paths,
However, you need to configure a lot of path information in the Squid configuration file.
2. rename files under the ETC folder
Squid.conf.default ==> squid.conf
Mime.conf.default ==> mime.conf
Cachemgr.conf.default ==> cachemgr.conf
3, simple configuration squid.conf, so that the configuration to achieve the effect of
Visible_hostname squidhost
#设定squid的主机名, no squid will start
Http_port 3128 accel vhost vport
# Set squid to Accel acceleration mode, vhost must be added. Otherwise, the host header cannot be forwarded to the back-end server,
#访问时就会出现无法找到主机头的错误
Cache_peer 147.151.240.234 parent 8080 0 No-query originserver round-robin name=webserver1
Cache_peer 147.151.241.151 parent 8080 0 no-query Originserver Round-robin name=webserver2
cache_peer_domain webserver1 webserver2 localhost
#将 localhost request via RR The polling method is forwarded to one of the 2 parent nodes.
#http://localhost:3128 requests are forwarded to 147.151.240.234:8080 or 147.151.241.151:8080
ACL all src 0.0.0.0/0.0.0.0
Http_access Allow all
4 to start squid
c:\squid\sbin>squid-z #创建cache目录.
C:\squid\sbin>squid #启动squid
Test:
launches 147.151.240.234 and 147.151.241.151 Tomcat and puts a test.jsp file on it.
The test.jsp output on the 151 machine is the JSP in Tomcat instance 151
test.jsp output on 234 machines The JSP in Tomcat instance 234
Access http:/ /localhost:3128/xxxweb/test.jsp will output the above results in turn.
access to a JSP is forwarded to the Web server each time: X-cache: miss from squidhost
- [Email protected]dora-wls9-1 bin]# curl-i http://147.151.240.52:3128/examples/jsp/test.jsp
- http/1.0 OK
- server:apache-coyote/1.1
- set-cookie:jsessionid=f3c10d53a916b1852d06687e9e581a2f; Path=/examples
- Content-type:text/html
- content-length:972
- DATE:FRI, Geneva 17:51:01 GMT
- X-cache:miss from Squidhost
- X-cache-lookup:miss from squidhost:3128
- via:1.0 squidhost:3128 (SQUID/2.6.STABLE22)
- Connection:close
Access to a static HTML is forwarded to the Web server each time: X-cache:hit from Squidhost
- [Email protected] bin]# curl-i http://147.151.240.52:3128/examples/jsp/test.html
- http/1.0 OK
- server:apache-coyote/1.1
- Accept-ranges:bytes
- etag:w/"26-1343982480000"
- LAST-MODIFIED:FRI, Geneva 08:28:00 GMT
- Content-type:text/html
- Content-length:26
- DATE:FRI, Geneva 17:28:54 GMT
- age:195
- <span style= "color: #FF0000;" ></span>x-cache:hit from Squidhost
- X-cache-lookup:hit from squidhost:3128
- via:1.0 squidhost:3128 (SQUID/2.6.STABLE22)
- Connection:close
Windows Squid Installation Configuration