Category Archives: Firewall

Khan academy offline (KALite) – Run on port 80

KALite is a great tool if you want to bring the resources available to an offline environment.

We run a virtual server with KALite. We point a DNS name at it an everything, but we don’t like that it runs on port 8008 rather than port 80.  Here is a recipe to make it work on a Debian 7 server without having to change configuration of the KALite script.

Problem: You can change KALite to run on port 80, but you have to run it as the root user, which it doesn’t want to do.

Solution: The firewall can automatically forward all traffic from port 80 to port 8008. KALite doesn’t know anything has changed.

Step 1 – Create a file on the debian server: 

nano /etc/network/if-pre-up.d/iptables

Step 2 – In that file paste this code:

#!/bin/sh
#Redirect all traffic from port 80 to port 8008
# (khan port)
iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8008

NOTE: The iptables command wraps here and it should be all one line when you paste it.

Step 3 – Chown file so it is owned by root:

chown root:root /etc/network/if-pre-up.d/iptables

Step 4 – Chmod file so it can be run:

chmod +x /etc/network/if-pre-up.d/iptables

Step 5 – Reboot:

Assuming you have KALite starting on reboot, you should be able to access it without the :8008 at the end now.

Written By: Ray Pulsipher