RPi as Access Point and Web Server

From Exceed Industries Wiki
Jump to navigation Jump to search

Goal

The project is intended to create a wireless access point with an integrated web server such that a device can connect via WiFi and access the hosted site. In fact, they will only be able to access the hosted site. I can imagine a few uses for this type of setup that would only require minimal changes such as a dead drop, a localized media stream, or similar proximity-dependent scenarios. My end goal is to use this in an promotional way such that users at a public event can connect to the AP and then read about a topic I present to them.

Parts and Tools

  • Raspberry Pi Zero W
  • Micro SD card, 8 GB
  • Micro SD to SD adapter
  • USB SD card reader
  • Micro USB power cable
  • Laptop
  • Working WiFi network

Process

  1. 3D printed a simple case for the Raspberry Pi.
  2. Download the Raspberry Pi OS Lite edition and transferred it to the micro SD card by following the instructions here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
  3. Set up RPi for headless operation:
    1. Allow it to connect to WiFi: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md
    2. Enable SSH: https://www.raspberrypi.org/documentation/remote-access/ssh/README.md
  4. Boot the RPi up.
  5. Locate the RPi on the wireless network and note down it’s IP address.
  6. Connect to the RPi via SSH using the default credentials: https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md
  7. Update the pi user’s password from the default.
  8. Check for and install all software updates and then reboot.
  9. Re-connect to the RPi via SSH.
  10. Download and install web server software. I installed Apache with the instructions here: https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
  11. Set up the RPi to act as an access point following the instructions here: https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md
    • However, I didn’t want to route AP client traffic anywhere and thus skipped the Enable routing and IP masquerading section.
    • I also encountered a syntax error with the dhcp-range line of the dnsmasq.conf file. Removing the “24h” lease time resolved this.
  12. Modified the /etc/dnsmasq.conf file, adding a wildcard to the address field such that all lookups will now resolve to the RPi’s static IP:
    • address=/#/10.0.0.1
  13. Test and verify that functionality so far is working as intended.
  14. Rather than create a website from scratch, I used the tool HTTrack to copy an existing site: https://www.httrack.com/
  15. Put the RPi’s SD card back into the card reader and moved the copied website files to the /var/www/html/ folder.
  16. Tweaked a few minor stylistic things in the HTML files, but this was all that was required to get the primary functionality working.