LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-12-2011, 02:30 AM   #1
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Squid proxy vs. local Apache vs. iptables


Hi,

I have a local gateway/firewall/proxy server/web server running Slackware64. I just installed and configured Squid on it, and it runs quite nice. I've configured iptables so all HTTP requests get redirected to port 3128 (Squid defaults), so I don't have to configure the proxy individually in every users' browser (and more important, they can't disable Squidguard filtering anymore ).

Here's what the according line in my rc.firewall looks like:

Code:
# Rediriger les requêtes HTTP vers le proxy Squid
$IPT -t nat -A PREROUTING -i $IFACE_LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
Now the problem is, I also have a local webserver running on that same machine. This server is not supposed to be accessible from the Internet, it merely serves as a local package repo for various Linux distros, for use with various netinstall CDs.

Question: how can I still go on using this server without requests being redirected to Squid? E. g. usually all port 80 requests get redirected to port 3128, except for this single machine. I sense the answer is a simple one-liner, but I'm stuck here. Too much coffee, not enough sleep.
 
Old 08-12-2011, 03:09 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
what do you mean "except for this single machine"? is this single machine not the proxy?

Generically you can just put a different aliased IP on the same interface to keep things very separate, or you can exclude the destination IP of the machine itself in that line, e.g add "-d ! 192.168.12.34" or whatever to that line.

Generally I don't like transparent proxies anyway, I'd not do that in the first place. There are good ways to stop people bypassing proxies by automatically configuring their browsers
 
Old 08-12-2011, 03:35 AM   #3
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Original Poster
Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Quote:
Originally Posted by acid_kewpie View Post
what do you mean "except for this single machine"? is this single machine not the proxy?

Generally I don't like transparent proxies anyway, I'd not do that in the first place. There are good ways to stop people bypassing proxies by automatically configuring their browsers
Well, I do need a transparent proxy here. It's for a network in a school - currently running a 100% CentOS-based network - and after a few months, most of the students had it figured out how to bypass proxy configuration in Firefox, which allowed them to happily surf porn sites and the likes.

By "except for this single machine", I mean requests for the Apache server on this machine:

Code:
http://192.168.2.1
 
Old 08-12-2011, 03:37 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by kikinovak View Post
Well, I do need a transparent proxy here. It's for a network in a school - currently running a 100% CentOS-based network - and after a few months, most of the students had it figured out how to bypass proxy configuration in Firefox, which allowed them to happily surf porn sites and the likes.
You're fixing the wrong problem. You need a firewall, they're probably still poking all sorts of holes you don't know about. They could easily run tor on your systems, right?? maybe they already are.

Quote:
Originally Posted by kikinovak View Post
By "except for this single machine", I mean requests for the Apache server on this machine:

Code:
http://192.168.2.1
right so try the -d ! suggestion
 
Old 08-12-2011, 04:24 AM   #5
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Original Poster
Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Code:
  # Rediriger les requêtes HTTP vers le proxy Squid, sauf celles pour le
  # serveur lui-même :
  $IPT -t nat -A PREROUTING -i $IFACE_LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
  $IPT -A INPUT -p tcp -i $IFACE_LAN --dport 80 -d 192.168.2.1 -j ACCEPT
The -d switch, of course. *facepalm*. Thanks!
 
Old 08-12-2011, 04:28 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
Originally Posted by kikinovak View Post
Code:
  # Rediriger les requêtes HTTP vers le proxy Squid, sauf celles pour le
  # serveur lui-même :
  $IPT -t nat -A PREROUTING -i $IFACE_LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
  $IPT -A INPUT -p tcp -i $IFACE_LAN --dport 80 -d 192.168.2.1 -j ACCEPT
The -d switch, of course. *facepalm*. Thanks!
well no, this shouldn't work, as the traffic is no longer on port 80 by the time it reaches the INPUT table.
 
Old 08-12-2011, 05:08 AM   #7
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Original Poster
Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Uh oh.

Code:
  # Rediriger les requêtes HTTP vers le proxy Squid, sauf celles pour le
  # serveur lui-même :
  $IPT -A INPUT -p tcp -i $IFACE_LAN --dport 80 -d 192.168.2.1 -j ACCEPT
  $IPT -t nat -A PREROUTING -i $IFACE_LAN -p tcp --dport 80 -j REDIRECT --to-port 3128
Better now?
 
Old 08-12-2011, 05:31 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
no, the order you write them doesn't matter as they are different tables.

as I said, try excluding the IP from the redirect:


$IPT -t nat -A PREROUTING -i $IFACE_LAN -d ! 192.168.2.1 -p tcp --dport 80 -j REDIRECT --to-port 3128
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to hide outside world local ip SQUID PROXY salimshahzad Linux - Server 1 02-09-2010 10:24 AM
Squid transparent proxy with iptables cksoo Linux - Server 5 06-12-2008 03:53 AM
squid proxy with iptables ssilayaraja Linux - Networking 7 04-14-2008 12:15 AM
IPTABLES for squid (Transparent proxy) kool_kid Linux - Networking 14 10-29-2007 10:45 AM
Double Proxy with Squid and iptables SatelliteThief Linux - Networking 1 10-18-2006 05:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration