Captive Portal?

Hi I was a little surprised that you don’t implement something like

Is there a reason not to?



We didn’t find one with a reliable behavior at the time we were building the original pi images. Many times on a mobile device, we found a captive portal would pull up a ‘log in’ screen, but that window didn’t have an address bar or browser functionality. Users would get trapped in it. It’s probably something that could be done and configured better nowadays, but we haven’t spent a lot of time keeping the pi deployments updated.

A volunteer, @jamesk has done a lot of phenomenal work on the pi platform lately.

Our RACHEL-Plus device does have a captive portal and a feature to turn that captive portal on or off.

1 Like

@sam_uk My initial goal was to just get the current RACHEL content shell and everything working with the pi again before making any major changes and a captive portal wasn’t implemented for the pi so I left it out. it is something I’ve looked at for future images but I found the ones available like nodogsplash have the issues @jeremy mentioned.

Captive portals are generally meant to force users to log in before using a server and RACHEL is open for anyone to connect to without logins. I will be adding redirect error pages to the next images for when an error happens or an invalid address is used. That will capture any wrong addresses and send people to a splash page to get back to RACHEL.

Is there another reason you’re looking for a splash page implementation?


Great, it was the redirect I was after, so anyone can find the open hotspot and find the content, rather than just confused.

No problem. Until that’s implemented, if you’re using the latest images at this post people can access RACHEL at www.rachel.pi or www.rachel which is easier than using an ip.


1 Like

Have you got any idea how you’ll impliment this? I’ve just broken a device trying, no big deal can reinstall, but would be good to know how to go about it?

The ErrorDocument would be done through the apache settings. The .conf file for the RACHEL content shell is at /etc/apache2/sites-available/contentshell.conf and I think the latest RACHEL-Pi images should already have this set up. There should be multiple lines of “ErrorDocument 404 redirect/404.php” and so on for each error. Since the DocumentRoot is /var/www, it will look for /var/www/redirect/404.php. So you can either create new php pages at /var/www/redirect/ or you can change /etc/apache2/sites-available/contentshell.conf to point to another file. If you point it back to /var/www/index.php you won’t ever know there was an error if one occurs, which isn’t great, but it would work.

You could download this file at the RACHEL github and put it in /var/www somewhere and then point the .conf to it and that would be a better solution. I was going to hook this up but there were issues so I hope it works for you.


1 Like

Great, thanks will have a go

Just looking at this now, could you say a bit more about ‘point.conf’ at it?

The /var/www file is below, which bit do I need to edit?

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ErrorDocument 404 redirect/404.php
ErrorDocument 500 redirect/500.php
ErrorDocument 502 redirect/502.php
ErrorDocument 503 redirect/503.php
ErrorDocument 504 redirect/504.php

    <Directory />
            Options -Indexes +FollowSymLinks
            AllowOverride None
            DirectoryIndex index.html index.php /_h5ai/server/php/index.php
    <Directory /var/www>
            Options -Indexes +FollowSymLinks +MultiViews
            AllowOverride None
            Order allow,deny
            allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel error

    CustomLog ${APACHE_LOG_DIR}/access.log combined

ErrorDocument 404 redirect/404.php
ErrorDocument 500 redirect/500.php
ErrorDocument 502 redirect/502.php
ErrorDocument 503 redirect/503.php
ErrorDocument 504 redirect/504.php

that means for error 404 page not found it will use /var/www/redirect/404.php for the error page. You need to change “redirect/404.php” to match a captive portal php page that you put in the /var/www/ folder or you can just put a file in /var/www/redirect and call it 404.php and see what happens.


1 Like

I put the file in /var/www renamed it to 404.php but nothing seems to have changed

did you put it in /var/www/redirect/404.php or /var/www/? It should be in /var/www/redirect/.

Sorry it is in fact in /var/www/redirect.

pi@rachel:/var/www/redirect $ ls
404.php captiveportal-redirect.php

/etc/apache2/sites-available/contentshell.conf contains the following

DocumentRoot /var/www
ErrorDocument 404 redirect/404.php
ErrorDocument 500 redirect/500.php

If I navigate to a 404 I see the below


It’s missing the / before /redirect haha. Sorry. That will fix it. So it should look like this

    DocumentRoot /var/www
    ErrorDocument 404 /redirect/404.php
    ErrorDocument 500 /redirect/500.php
    ErrorDocument 502 /redirect/502.php
    ErrorDocument 503 /redirect/503.php
    ErrorDocument 504 /redirect/504.php

If you’re going to use the captive portal php page from here, rename it to 404.php, and put it in the redirect folder you’ll need to change line 3 which is currently “require_once(“admin/common.php”);” to “require_once(”…/admin/common.php");" by adding that “…/” in front. Otherwise only a blank page will show. That page assumes it’s in /var/www but I am changing it to /var/www/redirect as there will be a lot of files as redirects for each error. Hope that works for you. it seems to work here.


Still not working I’m afraid

cd /var/www
pi@rachel:/var/www $sudo mkdir redirect
pi@rachel:/var/www $ cd redirect/
pi@rachel:/var/www/redirect $ sudo wget
–2019-07-09 06:14:04--
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1747 (1.7K) [text/plain]
Saving to: ‘captiveportal-redirect.php’

captiveportal-redirect.php 100%[=============================================================================>] 1.71K --.-KB/s in 0s

2019-07-09 06:14:04 (14.6 MB/s) - ‘captiveportal-redirect.php’ saved [1747/1747]

pi@rachel:/var/www/redirect $ sudo nano captiveportal-redirect.php

(contains /admin/common.php")

pi@rachel:/var/www/redirect $ sudo cp captiveportal-redirect.php 404.php
pi@rachel:/var/www/redirect $ sudo nano /etc/apache2/sites-available/contentshell.conf

(contains DocumentRoot /var/www
ErrorDocument 404 /redirect/404.php )

The 404.php has to have “…/admin/common.php”. The …/ has to be there. If you’re getting a blank page then that’s the issue. If you get an error saying there was an error handling the 404 then you may need to reload apache with “sudo systemctl reload apache2”. The other thing is you may need to set the ownership of the /var/www/redirect folder with “sudo chown -R www-data:www-data /var/www/redirect” if you made it with the root user. Other than that I’m not sure. Those are the only steps I did to get it working.


This is my /var/www/redirect/404.php /var/www/redirect/404.php -

This is my /etc/apache2/sites-available/contentshell.conf /etc/apache2/sites-available/contentshell.conf -

I’ve run sudo chown -R www-data:www-data /var/www/redirect

I’ve restarted apache2

This is what I get


Thanks for your patience with this one, I’m sure it’s something silly on my part.

No problem. Your 404 page doesn’t have “require_once(”…/admin/common.php");". Try this one

1 Like

Great that does work and correctly gives me a button on 404 pages.

Unfortunately, it’s not exactly what I’m after, I’m looking for something that redirects to when a user types ‘’ or whatever.

I’ll have a look at Dnsmasq

The images come with dnsmasq set up so users can get to rachel using “www.rachel.pi” or “www.rachel”. Those settings are stored in /etc/dnsmasq.conf. On some mobile devices like safari on iphones you have to add “http://” so “http://www.rachel.pi” or the browser won’t get there. Redirecting all sites would break the internet connection sharing functionality of RACHEL.

1 Like