I installed squid which is listening on port 3128. Now, I would like to show an error webpage to every user who tries to connect to any http/https webpage and doesnt have proxy set up. What parameter do I need to set up?

1 Answer 1


I don't think you can get squid to do this for you.

You need to redirect outgoing http/https traffic on your router to some local webserver that responsd with the given error page no matter what URL is requested.

The redirection is easiest when you have the webserver running on the gateway itself; you can then add rules like this:

iptables -t nat -A PREROUTING -p tcp --dport http -j REDIRECT
iptables -t nat -A PREROUTING -p tcp --dport https -j REDIRECT

This will send any traffic destined to those ports to the local system.

Note that for https traffic the use will get a certificate error, as the certificate used by the local system most certainly will not match the hostname requested.

On the webserver side you can use the index.html page with your message as the 404 error document, so that no matter what URL is requested, that page is served.

Of course the simplest way is just to reject all http/https traffic, the browser will give an error. You can use REJECT with --reject-with adm-prohibited, hopefully the browser will pass this status on to the user.

  • this is exactly what I want to do. I will try it. thank you
    – Peter
    Commented Jan 29, 2019 at 8:15
  • HTTP works great, now the question is https :) is there any way how to redirect all 443 traffic to the local error page?thanks
    – Peter
    Commented Jan 29, 2019 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .