Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 11-22-2006, 10:53 PM   #1
LQ Newbie
Registered: Oct 2005
Posts: 12

Rep: Reputation: 0
How to forward packets based on HTTP header content?

I'm looking for a way to route http request packets that arrive at our gateway to different hosts based on the contents of the http header. For example, requests for should be routed to one host, while requests to are to be routed to a different host.

Someone suggested using Squid in a reverse kinda way, but that seems kludgy.

The "strings" extension to iptables is reported to be dodgy.

Another suggestion is Apache reverse proxy.

If you've done this before, or know how to do it, please respond.
Old 11-22-2006, 11:49 PM   #2
Registered: Oct 2006
Location: Kenya
Distribution: Ubuntu, RHEL, OpenBSD
Posts: 287

Rep: Reputation: 32

hi have you thought of trying it using ipforwarding?
Am not quite sure why you specified HTTP alone but it should work.
The Linux kernel configuration parameter to activate this is named net.ipv4.ip_forward and can be found in the file /etc/sysctl.conf. Remove the "#" from the line related to packet forwarding.
PHP Code:
# Disables packet forwarding 
# Enables packet forwarding 
This enables packet forwarding only when you reboot at which time Linux will create a file in one of the subdirectories of the special RAM memory-based /proc filesystem. To activate the feature immediately you have to force Linux to read the /etc/sysctl.conf file with the sysctl command using the -p switch.
PHP Code:
[root@bigboy tmpsysctl -p
.ipv4.ip_forward 1
.ipv4.conf.default.rp_filter 1
.sysrq 0
.core_uses_pid 1
[root@bigboy tmp]
All the best.
Old 11-23-2006, 10:19 AM   #3
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
acid_kewpie answered it at
Old 11-23-2006, 08:54 PM   #4
Senior Member
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
This is not, strictly speaking, routing since it's operating at the application layer rather than the network layer. It also does not require packet forwarding, again because it's not at the network layer. Finally, it's not really based on content, it's based on the protocol-specific resource that the external client is trying to reach.

Now that all the technical terms are sorted, yes Apache with mod_proxy is exactly what you want. If you are still stuck after reading the posts from acid_kewpie, head over to and go to the documentation section for the relevant version of Apache.
Old 11-24-2006, 02:39 PM   #5
LQ Newbie
Registered: Oct 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for all the super help and info!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
content-length HTTP header MPowers Linux - Software 0 04-07-2006 03:01 PM
forward packets between two interfaces sehh Linux - Networking 2 08-30-2005 03:11 PM
forward IP based on http IP header freibuis Linux - Security 7 08-24-2004 12:21 AM
Forward netbios broadcast packets atlesn Linux - Networking 0 07-26-2004 09:37 AM
forward broadcast packets to another subnet VultureCulture Linux - Networking 9 10-25-2003 04:14 PM

All times are GMT -5. The time now is 04:58 AM.

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