Configuring the Captive Portal

Firstly, you need to configure raspberry pi as access point Setting up a Wi-Fi Access Point.

Installing a web server

sudo apt-get install apache2

Replace the placeholder page

Let’s browse to the /var/www/html directory and rename the default page:

cd /var/www/html/
mv index.html index.html.old

Now you can make a new folder and add your site in it.

Then you should make a new index.html file inside the folder /var/www/html for redirecting all requests to your site.

mkdir your-new-page/
sudo nano index.html

Paste the following

<html>
       <head>
               <meta HTTP-EQUIV="REFRESH" content="0; url=http://portal.mazizone.eu">
       </head>
       <body>
       </body>
</html>

Restart apache web server

sudo service apache2 restart

Redirect all to index.html via htaccess file

Enable and load mod_rewrite

sudo a2enmod rewrite

Then open up the following file, and replace “AllowOverride None” with “AllowOverride all”

sudo nano /etc/apache2/apache2.conf

Restart apache web server

sudo service apache2 restart

Finally, create a secret file .htaccess and import the following lines of code

sudo nano /var/www/html/.htaccess

Code of .htaccess file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]

MAZI backend

Note

For the configuration of the MAZI toolkit domain you can use the MAZI backend script mazi-domain.sh. Check more info here.

Examples of mazi-domain.sh usage:

  • Set the domain to new.domain.local
sudo sh mazi-domain.sh -d new.domain.local