RPi as Access Point and Web Server
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
- 3D printed a simple case for the Raspberry Pi.
- 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
- Set up RPi for headless operation:
- Allow it to connect to WiFi: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md
- Enable SSH: https://www.raspberrypi.org/documentation/remote-access/ssh/README.md
- Boot the RPi up.
- Locate the RPi on the wireless network and note down it’s IP address.
- Connect to the RPi via SSH using the default credentials: https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md
- Update the pi user’s password from the default.
- Check for and install all software updates and then reboot.
- Re-connect to the RPi via SSH.
- Download and install web server software. I installed Apache with the instructions here: https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
- 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 thednsmasq.conf
file. Removing the “24h” lease time resolved this.
- 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
- Test and verify that functionality so far is working as intended.
- Rather than create a website from scratch, I used the tool HTTrack to copy an existing site: https://www.httrack.com/
- Put the RPi’s SD card back into the card reader and moved the copied website files to the
/var/www/html/
folder. - Tweaked a few minor stylistic things in the HTML files, but this was all that was required to get the primary functionality working.