Virtual State of Jefferson Tech
Apr 20 2010, 10:55PM
My collaboration with Ethan Ham, Virtual State of Jefferson will be going up in Ashland at the Schneider Museum of Art next month. I wanted to describe a little about the tech work involved because I had fun, and it might be useful to others. The piece is a router running dd-wrt with an iptables rule that sends all traffic through a proxy. The proxy server is running squid, as well as nginx. Squid is configured with a redirect_program that does the following for each request:- Skip resources that are likely not text based (images, videos, etc)
- For text-based resources, grab the source and do a quick regex search for 'california', 'ca' or 'oregon'
- For resources that have one of the previous, do a full regex search/replace for cities in northern California, or southern Oregon that appear next to their state name/abbreviation (resulting in "Ashland, Jefferson" instead of "Ashland, Oregon", for example)
- Save the modified file on the nginx path, and transparently redirect the request to that file
#!/bin/sh
PROXY_IP=[proxy-ip]
PROXY_PORT=3128
LAN_IP=`nvram get lan_ipaddr`
LAN_NET=$LAN_IP/`nvram get lan_netmask`
if [ "$1" = "delete" ]; then
ACTION=D
else
ACTION=A
fi
cmd="iptables -t nat -$ACTION PREROUTING -s $LAN_NET -p tcp -m tcp --dport 80 -j DNAT --to-destination $PROXY_IP:$PROXY_PORT"
echo $cmd
$cmd
It's fun using sys-admin skills for an art project :D
Tags : networking nginx proxy regex
blog comments powered by Disqus