I am using Squid 3.0 and the following are not available.
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_head
Please advise
Main Topics
Browse All TopicsWe have a proxy server which is hosted at 192.168.102.3, running on port 8080.
This proxy is running Squid.
We have another linux server which provides DHCP, DNS, etc. for the 192.168.102.x network. What I want to do is, use IPTABLES on this server to direct all http traffic to our proxy.
Here are the 2 commands I am using.
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -s ! 192.168.102.3 -j DNAT --to-destination 192.168.102.3:8080
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -d 192.168.102.1 -RETURN
This does work as it redirects traffic to the proxy but the problem is, that squid doesn;t pick up the URL and comes up with an error.
Example:
http://www.google.com/ - is detected as - /
http://www.google.com/sear
Basically it strikes of the main URL completely and hence an error comes up saying INVALID URL. Anyone know how to fix it??
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I think the answer to my question might be in
http://kuscsik.blogspot.co
I am unable to access the server now, so I will have to try it on Monday when I get back to work.
Interesting that in SQUID 3.0 they have made it more simple than the previous versions.
Hope this works or I will be back on experts-exchange on Monday.
In the POSTROUTING chain you can see that all the traffic is MASQUREADEd. You should exclude all the traffic exiting on internal LAN from MASQUERADEing.
You can do this by inserting the rule:
iptables -t nat -I POSTROUTING -o eth0 -j ACCEPT
or by modifying the rule which now probably looks like:
iptables -t nat -A POSTROUTING -j MASQUERADE
to:
iptables -t nat -A POSTROUTING ! -o eth0 -j MASQUERADE
Hi Blaz,
This didn't work - iptables -t nat -I POSTROUTING -o eth0 -j ACCEPT
When I did it my proxy stopped working altogether.
2. iptables -t nat -A POSTROUTING ! -o eth0 -j MASQUERADE
This made no difference and the request still seem to be coming from 192.168.102.1
Also did you mean, run this in the following order -
iptables -t nat -I POSTROUTING -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING ! -o eth0 -j MASQUERADE
If this is what you meant I haven't tried. I juest ran them individually. Please comment.
I meant those two rules as alternatives.
Let me explain:
All the traffic from your internal lan (eth0) goes to your firewall (102.1) and when forwarding to internet you have to assign the firewalls public IP to the packets. You acomplish this with the command MASQUERADE (or you could have done it with a SNAT - source NAT). To the internet all the packets from your network seem to come from your firewall (a single machine).
The problem is that currently you are now forwarding traffic to an internal machine (the proxy) and obviously your rules do the MASQUERADING to that packets also (appearing to come from your firewall). This is not neccessary. You should make sure the MASQUERADING rules do not affect the traffic from your LAN to your proxy.
You have many MASQUREADING rules could you post them all? There may be some tricky rules at your site...
Could you also describe the machine - what interfaces does it have, how do you connect to the internet.
You could also change
iptables -t nat -I POSTROUTING -o eth0 -j ACCEPT
to:
iptables -t nat -I POSTROUTING -s 192.168.102.0/24 -o eth0 -d 192.168.102.3 -j ACCEPT
to catch only the traffic from your LAN to your proxy
Hi Blaz,
Posted all the MASQUERADING rules for you above.
"You could also change
iptables -t nat -I POSTROUTING -o eth0 -j ACCEPT
to:
iptables -t nat -I POSTROUTING -s 192.168.102.0/24 -o eth0 -d 192.168.102.3 -j ACCEPT
to catch only the traffic from your LAN to your proxy"
This still didn't fix the problem
No, that output is a bit short. I would be interested in the original rules in a script. This could be script /etc/sysconfig/iptables or rules listed in /etc/rc.local or a script called from there (maybe there is a call to iptables-restore).
At least post againt the output of:
/sbin/iptables -t nat -L -v -x
Additionally the output of the command would be usefull:
/sbin/ip rule list
There are several MASQURADE rules that MARK packets. Usually this is to change routing preferences.
Your request 1:
/sbin/iptables -t nat -L -v -x
Note I have reverted all the changes to original since what you suggested didn't work for me. At this point in time even these 2 commands are not active
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -s ! 192.168.102.3 -j DNAT --to-destination 192.168.102.3:8080
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -d 192.168.102.1 -RETURN
Your request 2:
/sbin/ip rule list
Note I have reverted all the changes to original since what you suggested didn't work for me. At this point in time even these 2 commands are not active
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -s ! 192.168.102.3 -j DNAT --to-destination 192.168.102.3:8080
iptables -t nat -I PREROUTING -i eth0 -p tcp --dport 80 -d 192.168.102.1 -RETURN
Could you describe your connection to the internet - you have two xDSLs with two public IPs or something like that?
What are the interfaces on the machine (eth0, eth2, ...)
The output of the following commands:
/sbin/iptables -t mangle -L -v -x
/sbin/ip rule list 1
/sbin/ip rule list 2
/sbin/ip rule list default
I must admit that the simptoms you describe confuse me somewhat.
You have some complicated firewall (and you don't know how it was set up) - marking of packets, routing depending on marking etc.
For example there are several MASQUERADING rules but it seems that only the first one is used (all traffic -> masquerade). The traffic you forward to your proxy should not be masqueraded and you will get the correct source IP on the proxy. Why it didn't work when implementing my suggested rules I don't know but they are in the right direction. With some iptables logging I believe you could figure it out.
I hope that my questions helped you understand your firewall a bit more.
Good luck
Business Accounts
Answer for Membership
by: BlazPosted on 2009-02-05 at 23:26:24ID: 23567460
You have to configure squid as a transparent proxy:
sparentPro xy.html ips/linux- setup-tran sparent-pr oxy- squid- howto.html
http://tldp.org/HOWTO/Tran
http://www.cyberciti.biz/t