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?


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.

| improve this answer | |
  • this is exactly what I want to do. I will try it. thank you – Peter Jan 29 '19 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 Jan 29 '19 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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