[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to port forward inside a folder ?



On 5/24/2012 3:11 AM, J. Bakshi wrote:
> Hello,
> 
> iptables port forwarding is running fine here.
> 
> 192.168.1.1:82 forwarded to 192.168.1.2:80
> 
> ``````````````````````
> # for 82 > 80 of 192.168.1.2
> iptables -A INPUT -p tcp -m tcp --dport 82 -j ACCEPT
> iptables -A PREROUTING -t nat -i ${LAN_IFACE} -p tcp --dport 82 -j DNAT --to 192.168.1.2:80
> iptables -A FORWARD -p tcp --dport 82 -i ${LAN_IFACE} -j ACCEPT
> 
> iptables -A PREROUTING -t nat -i ${WAN_IFACE} -p tcp --dport 82 -j DNAT --to 192.168.1.2:80
> iptables -A FORWARD -p tcp -d 192.168.1.2 --dport 80 -j ACCEPT
> ```````````````````````````
> 
> How can I forward inside a folder like
> 192.168.1.1:82 forwarded to 192.168.1.2:80/mysite

You can't do this with iptables.

> I have modified the rules as [.... --to 192.168.1.2:80/mysite ]
> but no success. Am I missing anything ?

You're confusing the application layer(7) with the network layer (3).
iptables works at layer 3 and is thus not aware of filesystem folders or
web directories.

You'll need to use http redirection to accomplish what you apparently
desire above, either with an http proxy or http server.

-- 
Stan


Reply to: