<document>
  <header>
    <product>resin</product>
    <title>Config Scrapbook</title>
    <version>Resin 3.0</version>
    <description>
      <p>A repository of notes and comments that will
        eventually make their way into the documentation.  Please
        treat the information here with caution, it has often not been
        verified.</p>
    </description>
  </header>

  <body>
    <faq title="alternative to making resin executable for binding to port 80 on Linux?">
      <description>
        <p>
        </p>
      </description>

      <section title="Linux 2.2.x">
        <example>
ipchains -A input -i eth+ -j REDIRECT 8080 -p tcp --destination-port 80
        </example>
      </section>


      <section title="Linux 2.4.x">
        <example>
IP=192.168.0.1

iptables -t nat -A PREROUTING -p tcp --dport 80 -d $IP -j DNAT --to $IP:8080

iptables -t nat -A PREROUTING -p tcp --dport 443 -d $IP -j DNAT --to $IP:8080
        </example>

<example>
#!/bin/sh
SCRIPTLOCATION="/usr/local/bin/iptables/"
IPLIST="192.168.3.160 192.168.3.161 192.168.3.162 192.168.3.163 192.168.3.164"
CURRENTIP=""
IPTABLES="/sbin/iptables"
#Clear out any existing firewall rules, and any chains that might have
#been created
$IPTABLES -F
$IPTABLES -F INPUT
$IPTABLES -F OUTPUT
$IPTABLES -F FORWARD
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X

for CURRENTIP in $IPLIST; do
	$IPTABLES -t nat -A PREROUTING -p tcp --dport 80 -d $CURRENTIP -j DNAT --to $CURRENTIP:8080
done

$IPTABLES -t nat -A PREROUTING -p tcp --dport 443 -d 192.168.3.164 -j DNAT --to 192.168.3.164:8443
	
$IPTABLES-save > $SCRIPTLOCATION/tablesave
</example>
      </section>

    </faq>
  </body>
</document>
