Raspberry Pi Configuration

We have built a Sherig-in-a-Box solution using a Raspberry Pi (model B).

Main features:

As configured, access to offline Wikipedia is done by pointing the browser to http://wiki.local. To access the offline version of Khan Academy, users point their browser to http://khan.local. Nginx will forward requests to the appropriate servers. Direct access is also available using respective port numbers (e.g., 10.0.0.1:8008), but this is less user-friendly.

Other incorporated changes include: using zram, disabling default swapping mechanisms, optimizations for extending the lifetime of the SD card, and many more.

Configuration files

We have been asked to share our config files and share them below in the hope the following list will be of help. This list is by no means exhaustive. 

 

/etc/init.d/hostapd

...

DAEMON_CONF=/etc/hostapd/hostapd.conf

...

/etc/hostapd/hostapd.conf

interface=wlan0

driver=nl80211

ssid=YourSSID

hw_mode=g

wpa=1

wpa_passphrase=mysecretpassword

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

channel=1

/etc/nginx/sites-available/default

server {

                server_name khan.local;

                location / {

                        proxy_pass http://localhost:8008;

                        proxy_buffering off;

                        proxy_cache off;

                        proxy_set_header Host $host;

                        proxy_set_header X-Real-IP $remote_addr;

                        proxy_set_header Connection '';

                        proxy_http_version 1.1;

                        chunked_transfer_encoding off;

                }

}

server  {

                server_name wiki.local;

                location / {

                        proxy_pass http://localhost:8888;

                        proxy_set_header X-Real-IP $remote_addr;

                }

}

server {

                listen 80 default_server;

                server_name _;

                location / {

                        root /usr/share/nginx/www;

                }

}

error_page 404 = /;

/etc/udhcpd.conf

start           10.0.0.20       

end             10.0.0.50 

interface       wlan0 

opt     dns     8.8.8.8 4.2.2.2

option  subnet  255.255.255.0

opt     router  10.0.0.1

opt     wins    192.168.10.10

option  domain  local

option  lease   864000          # 10 days of seconds

/etc/iptables.ipv4.nat

*filter

:INPUT ACCEPT [186:19057]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [160:40340]

-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT

-A FORWARD -i wlan0 -o eth0 -j ACCEPT

COMMIT

*nat

:PREROUTING ACCEPT [123:13642]

:INPUT ACCEPT [22:1470]

:OUTPUT ACCEPT [7:612]

:POSTROUTING ACCEPT [1:156]

-A POSTROUTING -o eth0 -j MASQUERADE

COMMIT

/etc/network/interfaces

auto lo

iface lo inet loopback

iface eth0 inet dhcp

up iptables-restore < /etc/iptables.ipv4.nat

iface wlan0 inet static

address 10.0.0.1

netmask 255.255.255.0

iface default inet dhcp