Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I managed to setup Squid3 on a Debian Squeeze 6.0 server in trasparent mode with iptables nat redirection.

All requests on port 80 are correctly redirected to squid and then compared with a whitelist file.

All requests to sites not covered by the whitelist are sent to the custom ERR_ACCESS_DENIED page. This page contains a simple login form.

So, when a site is blocked, the user has the ability to add that site to the whitelist.

I've created a very simple PHP script which takes the URL (with a regex), adds it to the whitelist and restarts squid.

At this point, i would to redirect the browser to the new authorized site, with a simple

$your_url =;
header("Location: $your_url");

but squid gives me an ERR_INVALID_URL page trying to retrive


If I try to type the url in the address bar, the site is correctly served.

I've tried to set a timeout in PHP before redirect, but even with a 1 minute timeout, the redirect fails. In the mean time, typing the url in the address bar works ok.

Any clue?

UPDATE Problem easly solved switching to Squid 2.7

Squid3 bug here

share|improve this question

Problem solved switching to Squid 2.7

share|improve this answer

I have a similar project called parentwall. I got around the issue by using squid -k reconfigure instead of restarting squid. You can do the same thing with the rc scripts.

Restarting squid takes forever and is unnecessary to reload the white list.

share|improve this answer

Just a thought, but it might be easier here to simply do a javascript redirect. So instead of trying to do a redirect with PHP simply return a page which has some javascript.

It is a bit less elegant, but it will probably be easier.

share|improve this answer
Javascript doesn't solve the problem. It is a squid bug documented here. – ilcartolaio Apr 27 '11 at 22:06
Given the way I read that, it seems like javascript could solve the problem if you put a sufficient delay in place to allow for the squid reconfigure to complete. In any case, you should add an answer and mark that as accepted. – Zoredache Apr 27 '11 at 22:44
The behavior is really strange. I've tried to put a delay in javascript as in php (1 minute) or print a link in the success page. The null bug appeared in both cases. – ilcartolaio Apr 28 '11 at 7:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.