Title: Squid&#8217;s HTTP Acceleration Mode
Author: Alex Kirk
Published: November 29, 2005

---

# Squid’s HTTP Acceleration Mode

November 29, 2005

I have recently configured a server of mine to use the [Squid Cache](http://www.squid-cache.org/)
in HTTP Acceleration mode. So what’s this anyway?

A typical request to a webserver looks like this: Client browser opens connection
to server port 80, server sends back the data through that connection. For the time
of the transfer the server “loses” one child process. So if a client with a slow
connection requests a large file this can take some minutes. If many slow clients
block child processes, eventually too few will be left for “ordinary” clients.

A solution for this is to prepend a proxy server to the HTTP server. The proxy server
is lightweight and does the communication with the client browser. The communication
with the web server is done via a high speed interface (either loopback when it’s
just one server or an lan with 100(0) mbit), so almost no time is spent waiting 
for a transfer to finish.

Setup is easy, and I’ve [covered this in my thesis](https://alex.kirk.at/papers/caching-strategies/diploma_thesisch6.html#x17-750006.2)
already.

But I’ve got some more real-life info for you.

There are two usual ways for setting this up.

 1. Set the web server to listen on port 81, Squid on 80.
 2. Web server still listens on port 80 but just for 127.0.0.1, the loopback interface.
    Squid listens on port 80 on the external interface.

What makes number two the favourable is that you are not haveing a server process
listening on an unconventional port, and, for redirects (`Location: /somewhereelse`)
the port number is correct (see the [corresponding question in the Squid FAQ](http://www.squid-cache.org/Doc/FAQ/FAQ-20.html#ss20.3)).
For existing configurations with virtual hosts there is no need to change a `< VirtualHost*:
80>` to `< VirtualHost *:81>`.

So in `ports.conf` of Apache, for example, you change this:
 ` # Listen 80 Listen
127.0.0.1:80

In `squid.conf` you do these changes (apart from those listed in [my thesis](https://alex.kirk.at/papers/caching-strategies/diploma_thesisch6.html#x17-750006.2)):
`#
http_port 3128 http_port ip.add.re.ss:80

So this works nice already, but there is one more thing. Now the source address 
for a http request is `127.0.0.1`. So if you want to do some processing with the`
REMOTE_ADDR`, for example in PHP, you’d have to insert something like this before
you’d could use the address again.
 ` if (isset($_SERVER["HTTP_VIA"])) { // squid
http accel $_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_X_FORWARDED_FOR"]; }

Also in the log files there is now a `127.0.0.1` as source instead of the real ip
address. The following changes things back to normal (in `apache2.conf`):
 ` # LogFormat"%
h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined LogFormat "%{X-Forwarded-
For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined

This should be all for now. Happy speed-boosting ;)

[Misc](https://alex.kirk.at/category/misc/), [Web](https://alex.kirk.at/category/web/)

Read this next

[Favicon caching](https://alex.kirk.at/2005/11/28/favicon-caching/)

## 6 responses to “Squid’s HTTP Acceleration Mode”

 1.  [alexander kirk » Blog Archive » 10 Steps to a Faster Web Site](http://alex.kirk.at/2006/02/02/10-steps-to-a-faster-web-site/)
 2.  [February 2, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-134)
 3.  […] So there is a solution for this. The well known Squid proxy has a HTTP Acceleration
     mode which handles communication with the client. It’s like a secretary that handles
     all communication. […]
 4.  [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)
 5.  ![Geoff Hallford Avatar](https://secure.gravatar.com/avatar/abb16ef5c2b71cca7f58da5041a8e6c6b1900d7b565643c8f1457548480ddd4e?
     s=48&d=mm&r=g)
 6.  [Geoff Hallford](http://www.hallford.ca)
 7.  [February 3, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-156)
 8.  Hey,
 9.  I tried setting up the Squid accel proxy and it works but not 100%. One problem
     is that if I go to the site to a directory without the trailing slash and not 
     a specific file, it says ‘Rejected by 127.0.0.1’.
 10. Works: ‘http://www.hallford.ca/webmail’
      Doesn’t Work: [http://www.hallford.ca/webmail/](http://www.hallford.ca/webmail/)‘
 11. Any ideas on how to fix this?
 12. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)
 13. ![Geoff Hallford Avatar](https://secure.gravatar.com/avatar/abb16ef5c2b71cca7f58da5041a8e6c6b1900d7b565643c8f1457548480ddd4e?
     s=48&d=mm&r=g)
 14. [Geoff Hallford](http://www.hallford.ca)
 15. [February 3, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-157)
 16. Sorry should be:
 17. Works: [http://www.hallford.ca/webmail/](http://www.hallford.ca/webmail/)
      Doesn’t
     Work: [http://www.hallford.ca/webmail](http://www.hallford.ca/webmail)
 18. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)
 19. ![Alexander Kirk Avatar](https://alex.kirk.at/wp-content/uploads/sites/2/2025/
     06/cropped-2025.Alex-512x512-1-48x48.jpg)
 20. [Alexander Kirk](http://alex.kirk.at/)
 21. [February 5, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-182)
 22. Hm, both work for me ;)
      I don’t know an exact solution but an important thing
     is that the server variable REMOTE_ADDR is not set correctly when using Squid 
     as the webserver now communicates only with clients (=squid) from localhost (=
     127.0.0.1). So maybe you don’t allow redirects for requests from localhost?
 23. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)
 24. [XOOPS CHINA – WordPress](http://xoops.org.cn/modules/wordpress/?p=276)
 25. [February 14, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-197)
 26. […] So there is a solution for this. The well known Squid proxy has a HTTP Acceleration
     mode which handles communication with the client. It¡¯s like a secretary that 
     handles all communication. […]
 27. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)
 28. [Airabove | Online portfolio of swedish web designer and graphical artist Robert Arnesson](http://www.airabove.com/index.php/67)
 29. [April 19, 2006](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/comment-page-1/#comment-598)
 30. […] So there is a solution for this. The well known Squid proxy has a HTTP Acceleration
     mode which handles communication with the client. Itâ€™s like a secretary that
     handles all communication. […]
 31. [Log in to Reply](https://alex.kirk.at/wp-login.php?redirect_to=https%3A%2F%2Falex.kirk.at%2F2005%2F11%2F29%2Fsquids-http-acceleration-mode%2F)

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2005/11/29/squids-http-acceleration-mode/?output_format=md#respond)󠁿

Only people in [my network](https://alex.kirk.at/friends/) can comment.

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)