|
||||||
| | Introduction | What is Reverse Proxy Cache |
About Squid | How Reverse Proxy Cache work
| Configuring Squid
as Reverse Proxy | Configuring Squid as
Reverse Proxy for Multiple Domains | References
| Conclusion | About
ViSolve.com | |
||||||
Introduction |
This document describes reverse proxies, and how they are used to improve Web server performance. Section 1 gives an introduction to reverse proxies, describing what they are and what they are used for. Section 2 compares reverse proxy caches with standard and transparent proxy caches, explaining the different functionality each provides. Section 3 illustrates how the reverse proxy actually caches the content and delivers it to the client. Section 4 describes how to configure Squid as a reverse proxy cache. | |||||
What is Reverse Proxy Cache |
Reverse
proxy cache, also known as Web Server Acceleration, is a method of
reducing the load on a busy web server by using a web cache between the
server and the internet. Another benefit that can be gained is improved
security. It's one of many ways to improve scalability without
increasing the complexity of maintenence too much. A good use of a
reverse proxy is to ease the burden on a web server that provides both
static and dynamic content. The static content can be cached on the
reverse proxy while the web server will be freed up to better handle
the dynamic content. By deploying Reverse Proxy Server alongside web servers, sites will:
The objective of this white paper is to explain the implementation of Squid as a Reverse-proxy also known as Web Server-accelerator. The basic concept of caching is explained followed by the actual implementation and testing of the reverse-proxy mode of squid. |
|||||
About Squid |
Squid is an
Open
source
high-performance Proxy caching server designed to run on Unix systems.
National Science Foundation funds squid project, Squid has its presence
in numerous ISP's and corporate around the globe. Squid can do much
more than what most of the proxy servers around can do. Reverse Proxy compared with other Proxy caches There are three main ways that proxy caches can be configured on a network :
|
|||||
How Reverse proxy caches work |
A reverse proxy
is positioned between the internet and the
web server
The four most important header tags are: Last-Modified: Tells the proxy when the page was last modified.Expires: Tells the proxy when to drop the page from the cache. Cache-Control: Tells the proxy if the page should be cached. Pragma: Also tells the proxy if the page should be cached. For example, by default all Active Server Pages return "Cache-control: private." Therefore, no Active Server Pages will be cached on a reverse proxy server. |
|||||
Configuring Squid as Reverse Proxy (http accelerator) |
To set up
Squid
as an httpd accelerator, you simply configure the
squid.conf file. Usually it is found in either /usr/local/squid/etc,
when installed directly from source code, or /etc/squid when
pre-installed on Red Hat Linux systems. The squid.conf file is used to
set and configure all the different options for the Squid proxy server.
As root open the squid.conf file in your favorite text editor. If the
real web server runs on a separate machine than the Squid reverse
proxy, edit the following options in the squid.conf file : http_port 80 #
Port of Squid proxy
httpd_accel_host 172.16.1.115 # IP address of web server httpd_accel_port 80 # Port of web server httpd_accel_single_host on # Forward uncached requests to single host httpd_accel_with_proxy on # httpd_accel_uses_host_header off If the web server runs on the same machine where Squid is running, the web server daemon must be set to run on port 81 (or any other port than 80). With the Apache web server, it can done by assigning the line "Port 80" to "Port 81" in its httpd.conf file. The Squid.conf must also be modified to redirect missed requests to port 81 of the local machine : http_port 80 #
Port of Squid proxy
httpd_accel_host localhost # IP address of web server httpd_accel_port 81 # Port of web server httpd_accel_single_host on # Forward uncached requests to single host httpd_accel_with_proxy on # httpd_accel_uses_host_header off We describe these options in greater detail. http_port 80
The option http_port specifies the port number where Squid will listen for HTTP client requests. If this option is set to port 80, the client will have the illusion of being connected to the actual web server. This options should always be port 80. httpd_accel_host
172.16.1.115 and httpd_accel_port 80
The options httpd_accel_host and httpd_accel_port specify the IP address and port number of the real HTTP Server, such as Apache. In our configuration, the real HTTP Web Server is on the IP address 172.16.1.115 and on port 80. If we are using the reverse proxy for more than one web server, then we must use the word virtual as the httpd_accel_host. Uncached requests can only be forwarded to one port. There is no table that associates accelerated hosts and a destination port. When the web server is running on the same machine as Squid, set the web server to listen for connections on a different port (8000, for example), and set the httpd_accel_port option to the same value. httpd_accel_single_host
on
To run Squid with a single back end web server, set httpd_accel_single_host option to on. Squid will forward all uncached requests to this web server regardless of what any redirectors or Host headers says. If the Squid reverse proxy must support multiple back end web servers, set this option to off, and use a redirector (or host table or private DNS) to map the requests to the appropriate back end servers. Note that the mapping needs to be a 1-1 mapping between requested and backend (from redirector) domain names or caching will fail, as caching is performed using the URL returned from the redirector. See also rewrites_host_header. httpd_accel_with_proxy
on
httpd_accel_uses_host_header off Requests in HTTP version 1.1 include a Host header, specifying the host name (or IP address) of the URL. This option should remain off in reverse proxy mode. The only time this option must be set to on is when Squid is configured as a Transparent proxy. It's important to note that acls (access control lists) are checked before this translation. You must combine this option with strict source-address checks, so you cannot use this option to accelerate multiple back end servers. |
|||||
Configuring Squid as Reverse Proxy for Multiple Domains (http accelerator) |
You can
configure
squid in an accelerator mode for multiple domains
also. For example you can configure single squid machine for
www.abc.com, www.xyz.com, www.lmn.com. Squid configuration httpd_accel_host
virtual
httpd_accel_port 80 (the web server port) httpd_accel_single_host off (It should be disabled when we are going to the reverse proxy for multiple servers) httpd_accel_uses_host_header on Note: When you compile Squid enable the Internal DNS option To set the reverse proxy for the domain www.abc.com 192.168.1.2 www.xyz.com 192.168.1.2 www.lmn.com 192.168.1.2 Let reverse_proxy server ip be 192.168.1.2 DNS entry in the reverse proxy server You need to configure Intranet DNS and Internet DNS. You can configure split DNS if you want both the DNS in same machine. Instead of Intranet DNS you can have domain entries in /etc/hosts. You have to configure squid with --disable-internal-dns to use /etc/hosts file lookup.
Note: If you have compiled with disable internal dns, then add the entry in the /etc/hosts like 172.16.1.2 www.abc.com 172.16.1.3 www.xyz.com 172.16.1.4 www.lmn.com Internal DNS entry www.abc.com 192.168.1.2 www.xyz.com 192.168.1.2 www.lmn.com 192.168.1.2 |
|||||
References |
ViSolve
Squid Configuration Manual 2.4 ViSolve Squid Configuration Manual 3.0 |
|||||
Conclusion |
Reverse proxying is a special proxy deployment used to reduce load on a web server. The reverse proxy server is placed outside the firewall, acting as the web server to external clients. Cached requests are sent back directly to the clients without any computation from the actual web server. Uncached requests must be forwarded to the backend web server, and the response from the web server is then cached in the reverse proxy. | |||||
|
About ViSolve.com ViSolve is an international corporation that provides technical services, for Internet based systems, for clients around the globe. ViSolve is in the business of providing software solutions since 1995. We have experience of executing several major projects and we are now completely focused on leading Internet technologies, Testing QA and support. We are committed to the Open source movement and in the same lines we provide free support for products like Linux, Apache and Squid to the user community. |
||||||
| Document Version : 1.0 | Created On : 28-01-02 | Updated On : 30-05 -06 |
||||||