|
|
Line 1: |
Line 1: |
− | Lets set up our map server with local cached image files
| |
| | | |
− | == Installing required software ==
| |
− |
| |
− | Install nginx (server), hostapd (wifi AP host), dnsmasq (light dns server)
| |
− | [http://elinux.org/RPi_Nginx_Webserver install Nginx]
| |
− | <nowiki>
| |
− | sudo apt-get update
| |
− | sudo apt-get install nginx
| |
− | sudo apt-get install hostapd
| |
− | sudo apt-get install dnsmasq
| |
− | </nowiki>
| |
− |
| |
− | == Web Server ==
| |
− |
| |
− | Set up web server to forward 404's to root directory (needed for captive portal behaviour) and start
| |
− | edit /etc/nginx/sites-available/default
| |
− |
| |
− | and modify line in "location / {" section:
| |
− | <nowiki>
| |
− | try_files $uri $uri/ = 404;
| |
− | </nowiki>
| |
− | becomes
| |
− | <nowiki>
| |
− | try_files $uri $uri/ /index.html;
| |
− | </nowiki>
| |
− |
| |
− | Now start the server
| |
− | <nowiki>
| |
− | sudo service nginx start
| |
− | </nowiki>
| |
− |
| |
− | == Set up hostapd ==
| |
− |
| |
− | Set up AP with hostap (instructions from [http://elinux.org/RPI-Wireless-Hotspot set up AP with udhcpd])
| |
− | edit the file /etc/hostapd/hostapd.conf
| |
− | <nowiki>
| |
− | interface=wlan0
| |
− | ssid=TacticalSpaceLab
| |
− | hw_mode=g
| |
− | channel=6
| |
− | auth_algs=1
| |
− | wmm_enabled=0
| |
− | </nowiki>
| |
− | Edit the file /etc/default/hostapd and change the line:
| |
− | <nowiki>
| |
− | #DAEMON_CONF=""
| |
− | </nowiki>
| |
− | to
| |
− | <nowiki>
| |
− | DAEMON_CONF="/etc/hostapd/hostapd.conf"
| |
− | </nowiki>
| |
− | Start it up, and add it to start at boot
| |
− | <nowiki>
| |
− | sudo service hostapd start
| |
− | sudo update-rc.d hostapd enable
| |
− | </nowiki>
| |
− |
| |
− | === Note for EDIMAX adaptors ===
| |
− |
| |
− | [http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/ edimax version of hostapd if using an edimax wifi usb]
| |
− |
| |
− |
| |
− | == DHCP and DNS for access point and captive portal ==
| |
− |
| |
− | Set up /etc/network/interfaces for serving DHCP and DNS
| |
− | <nowiki>
| |
− | auto lo
| |
− | iface lo inet loopback
| |
− |
| |
− | auto wlan0
| |
− | iface wlan0 inet static
| |
− | address 10.1.2.1
| |
− | netmask 255.255.255.0
| |
− | network 10.1.2.0
| |
− |
| |
− | </nowiki>
| |
− | configure dnsmasq /etc/dnsmasq.conf
| |
− | <nowiki>
| |
− | # captive portal to this
| |
− | no-resolv
| |
− | server=/localnet/10.1.2.1
| |
− | server=/tacticalspace/10.1.2.1
| |
− | address=/#/10.1.2.1
| |
− | interface=wlan0
| |
− | dhcp-range=10.1.2.5,10.1.2.200,12h
| |
− | </nowiki>
| |
− | restart dnsmasq
| |
− | <nowiki>
| |
− | sudo /etc/init.d/dnsmasq restart
| |
− | </nowiki>
| |
− |
| |
− | == More Captive Portal Stuff ==
| |
− |
| |
− | [http://stackoverflow.com/questions/3615147/how-to-create-wifi-popup-login-page Pop up page info for IOS, Windows, and Android]
| |
− | [http://serverfault.com/questions/446674/how-to-configure-nginx-to-redirect-all-request-from-domain-aliases-to-main-domai forward to domain]
| |
− | [https://www.raspberrypi.org/forums/viewtopic.php?t=90155&p=764850 iptables nat stuff for captive portal]
| |
− |
| |
− | == Logging people ==
| |
− | if you want dnsmarsq script logging...
| |
− | Create /var/log/dhcp_leases file with write
| |
− | create /usr/bin/logdhcp, make executable
| |
− | add it to dnsmasq config
| |
− | <nowiki>
| |
− | #!/bin/bash
| |
− | destfile=/var/log/dhcp_leases
| |
− | #if [ "$1" == "add" ]
| |
− | #then
| |
− | if [ -f "$destfile" ]
| |
− | then
| |
− | echo "$1 $2" >> "$destfile"
| |
− | fi
| |
− | #fi
| |
− | </nowiki>
| |
− | [[File:logging_dhcp.png|thumbnail]]
| |
− |
| |
− | ended up using dnsmasq for DNS and DHCP. Setting DNS forward IP to local for captive portal setup
| |
− |
| |
− | == Map framework ==
| |
− |
| |
− | Copy the server framework files across
| |
− |
| |
− | [http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=39225 some popup mehods]
| |
− |
| |
− | place javascript files and map tiles into /var/www/html
| |
− |
| |
− | [http://maps.tacticalspace.org/var-MQ-Feb2015.zip MQ var directory archive]
| |
− |
| |
− | Remember to make all /var/www/html folders readable with:
| |
− | <nowiki>
| |
− | sudo find /var/www/html -type d -exec chmod a+x {} +
| |
− | sudo find /var/www/html -type d -exec chown root:root {} +
| |
− | sudo find /var/www/html -type f -exec chmod a+r {} +
| |
− | sudo find /var/www/html -type f -exec chown root:root {} +
| |
− | </nowiki>
| |
− |
| |
− | == For Map content ==
| |
− |
| |
− | [http://mapnik.org/ MapNik coding platform for maps... pull render tiles using this?]
| |
− | [http://maps.stamen.com/m2i/image/20130610/mapstack_ZHVazuJTG7s beautiful Stamen Design map that can be used]
| |
− | [[File:Map example1.png|thumbnail]]
| |
− | [[File:Map example2.png|thumbnail]]
| |