How to set up reverse proxy for single web server using Squid
For high-traffic web servers, there are many approaches for extending scalablity. Reverse Proxy is one of those approaches especially for servers with lots of static files, e.g., images and other media. These static files usually are never changed over time. Storing many thousand files in normal filesystem is not efficient due to limitation of inode lookup in large directories. However, it is possible to tune up the overall performance without modifying the existing codes to prevent too large directories. It is the reverse proxy. You don't need to buy it because it is available for free in Squid. In this case, I only focus in the case that you have a single web server. If you have multiple web servers, you need to adjust the setting a little bit.
All you need to do is to use below configuration as your template.
http_port 80
httpd_accel_host 192.168.0.2
httpd_accel_port 80
httpd_accel_single_host on
httpd_accel_with_proxy off
httpd_accel_uses_host_header on
Below is the detail.
-
http_port
is the port for this reverse proxy. Normally, it should be80
. -
httpd_accel_host
is the IP address of the real web server. -
httpd_accel_port
is the port of the real web server.
That's all. Note that this setting also supports name-based virtualhost without explicit IP and host mapping in /etc/hosts
or internal DNS.
Tags: reverse proxy, squid, virtualhost
- sugree's blog
- 1389 reads
Post new comment