LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Only allow HTTP access through proxy? (https://www.linuxquestions.org/questions/linux-security-4/only-allow-http-access-through-proxy-322277/)

gjhicks 05-11-2005 03:38 AM

Only allow HTTP access through proxy?
 
Hello,

Have got a linux server working, with 2 NICs, using firestarter and privoxy, taking data from a adsl modem/router and feeding it to a wireless based lan.

All seems to be fine and the privoxy stuff works but the downstream lan users can still bypass the proxy, by just not setting the proxy, that is by direct access to http via port 80.

I am sure that this can be blocked/denied by a call to iptables (which I use for nat) but can't figure out the exact syntax.

Would appreciate some assistance.

Regards,

Geoff.

win32sux 05-11-2005 05:34 PM

sounds like what you want to do is transparent proxying... by doing it like this, all tcp port 80 packets going from the lan to the internet will be redirected automatically to the proxy... this way the machines on the lan don't even need to be configured to use a proxy, the proxying becomes transparent to the users on the lan... this is what the iptables rule would look like if eth1 is your lan interface and your proxy is listening on port 3128:
Code:

iptables -t nat -A PREROUTING -p TCP -i eth1 --dport 80 \
-j REDIRECT --to-ports 3128

also keep in mind that you'll probably need to configure your privoxy to be able to work transparently... i'm not sure how that works with privoxy, but on squid basically all you need to do is add these lines to your squid.conf:
Code:

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

squid would also need to be compiled using the --enable-linux-netfilter option...

http://www.tldp.org/HOWTO/TransparentProxy.html

just my :twocents:, good luck...


win32sux 05-11-2005 06:09 PM

i just found this in the Privoxy Faq (Section 3.18):
Quote:

Can Privoxy run as a "transparent" proxy?

No, Privoxy currently does not have this ability, though it is planned for a future release. Transparent proxies require special handling of the request headers beyond what Privoxy is now capable of.

Chaining Privoxy behind another proxy that has this ability should work though. See the forwarding chapter in the user manual.
so it looks like for now you'd have to install something like squid anyways in order to get privoxy to work in a transparent fashion for your lan...


gjhicks 05-11-2005 09:19 PM

Thanks for your help. This is proving to be a fair bit more complicated than I expected. But with kids and the internet, what is the choice?

One other question, in you post you mention:

sounds like what you want to do is transparent proxying... by doing it like this, all tcp port 80 packets going from the lan to the internet will be redirected automatically to the proxy...

Sorry to appear thick but what about the tcp port 80 packets going from the internet to the lan?

Regards,

Geoff.

win32sux 05-11-2005 09:27 PM

Quote:

Originally posted by gjhicks
but what about the tcp port 80 packets going from the internet to the lan?
there wouldn't be any... the machines on your lan would be establishing a connection to the proxy server... the proxy server would establish a connection to the internet... there wouldn't be any 80/tcp connection between the lan and the internet at any point...

gjhicks 05-11-2005 11:08 PM

thanks again, I guess I should have tumbled to that.

I don't mind having to configure the kids computers to use the privoxy port but, as I said earlier, denying access to the "raw" http port 80 is also an aim.

Am I right in assuming that the code mentioned above:

iptables -t nat -A PREROUTING -p TCP -i eth1 --dport 80 \
-j REDIRECT --to-ports 3128

will mean that computers on the lan connected via eth1 will not have access to port 80?

thanks and regards,

Geoff.

win32sux 05-12-2005 01:26 AM

i see what you mean now...

in that case, you can block all forwarding of 80/TCP packets by executing this command (assuming eth1 is your LAN interface):

Code:

iptables -I FORWARD -p TCP -i eth1 --dport 80 -j REJECT
this would prevent them from surfing the web directly through the NAT firewall, so they'd only be able to do it by connecting to the privoxy port...

if you don't wanna mess with your current firewall configuration just add that command to your startup file (maybe rc.local) and you should be fine...

by doing it like this you don't need to worry about the transparent proxying stuff anymore... :)

i hope this helps... good luck!!!


gjhicks 05-12-2005 04:52 AM

Yes, I just want a way to deny the lan users access to the "usual" http port.

Thanks a lot for your assistance.

Regards,

Geoff.


All times are GMT -5. The time now is 06:42 PM.