I'm trying to make a captive portal with apache as a server and a raspberry pi on AP mode. I have some trouble trying to make the captive portal splash, I tried all tutorials on the internet and I can't make it.

My dhcpcd.conf

slaac private
interface wlan0
static ip_address=
nohook wpa_supplicant

My dnsmasq.conf

# Use interface wlan0  
address= /#/


       # Use Cloudflare DNS  
 # IP range and lease time

My configuration for my server on apache is

<VirtualHost :>

        ServerName connectivitycheck.gstatic.com
    DocumentRoot /var/www/html/AP_mode

RewriteCond %{REQUEST_URI} !=/index.html
        RewriteRule ^(.*)$ [L]
        ErrorDocument 404

        RedirectMatch 302 /generate_204

ErrorLog ${APACHE_LOG_DIR}/android_error.log
CustomLog ${APACHE_LOG_DIR}/android_access.log combined

thanks for your help guys!

  • edit1->

The mechanism that i'm trying to build is a page who is display as a captive portal when the user connect to my raspberry pi who is in AP mode. In that page, the user has to put some information and the information will help tha raspberry pi in the futur( the management of the information is already okey) My only problem is that my page doesnt displat anything

here you can see the logs of the requests here - - [13/Feb/2020:06:24:00 -0400] "GET /generate_204 HTTP/1.1" 302 554 "-" "Dalvik/2.1.0 (Linux; U; Android 9; SM-G965W Build/PPR1.180610.011)" - - [13/Feb/2020:06:24:00 -0400] "GET /generate_204 HTTP/1.1" 302 554 "-" "Dalvik/2.1.0 (Linux; U; Android 9; SM-G965W Build/PPR1.180610.011)" - - [13/Feb/2020:06:24:00 -0400] "GET /generate_204 HTTP/1.1" 302 554 "-" "Dalvik/2.1.0 (Linux; U; Android 9; SM-G965W Build/PPR1.180610.011)" - - [13/Feb/2020:06:24:01 -0400] "GET /generate_204 HTTP/1.1" 302 554 "-" "Dalvik/2.1.0 (Linux; U; Android 9; SM-G965W Build/PPR1.180610.011)" - - [13/Feb/2020:06:24:01 -0400] "GET /generate_204 HTTP/1.1" 302 554 "-" "Dalvik/2.1.0 (Linux; U; Android 9; SM-G965W Build/PPR1.180610.011)"

how you can see, there's the request of my phone who receive a 302 response, im suposed to recive a 204 have my captivep portal splash mode displaying -maybe the iptables rules are the problem? i dont use any for the moment but all request are supossed to be redirected to my apache page

  • What problem are you having? (Please edit it into the question.)
    – Mark Smith
    Feb 17, 2020 at 21:02
  • you can see the edit1 thank you for your help! Feb 18, 2020 at 13:24

1 Answer 1


At first, make sure you have configured the raspberry pi as a Wifi hotspot and check it on other devices. If other devices can connect to the AP of your raspberry pi and they get an IP address, follow this answer.

The apache.conf is the problem. Take a look at how the Splash page of a captive portal works!

Every operating system has its own different way of detecting Internet access. The mechanism is this basically:

GET/POST http://x.com/bar.html
If bar.html == [expected content] > Open Internet
If bar.html != [expected content] > Captive Portal
If bar.html[status] != SUCCESS > No Network  

Each device, also Android different manufactures, behaves differently. For example, look at the list below for different manufactures/devices:

Sony Xperia Z5:
Samsung Galaxy J3 2016:
Samsung Galaxy J7 2015:
galaxy note4:
iOS 11:
Windows 10:

I suggest making another apache config file for specific device/manufacture.

Create a directory for android in apache directory:

cd /var/www/html/
sudo mkdir android 

Create a simple index.html file that is going to appear on the splash page of the android device.

Create android.conf with touch/nano and copy the following code to create a "redirection rule" for Android devices.

sudo nano /etc/apache2/sites-enabled/android.conf  

Put these lines:

<VirtualHost *:80>

    Servername connectivitycheck.gstatic.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/android

    RedirectMatch 302 /generate_204 /index.html

    ErrorLog ${APACHE_LOG_DIR}/android_error.log
    CustomLog ${APACHE_LOG_DIR}/android_access.log combined


Save file and exit.

Now, everything is done for android devices that are requesting to connectivitycheck.gstatic.com after connecting to a captive portal system.

Follow the procedure for other devices. Also, check THIS LINK out to get more information.

If the operating system is not important, you can install OpenWrt on your raspberry pi and then install and configure NoDogSplash as the captive portal. Check THIS LINK out to do it by OpenWrt.
Feel free to comment if you don't understand what's OpenWrt and how does it work as a Wifi hotspot and captive portal.

  • i already use that methode but when i use it, i dont even have logs on my logs-page I juste need the splash page for android thats why im using connectivitycheck.gstatic.com thank you for your help it's really important for me Feb 18, 2020 at 13:31
  • @CesarBeltran Yes, must of Android devices check the connectivitycheck.gstatic.com for internet connectivity. Check this link that I suggested. It's really helpful.
    – M. Rostami
    Feb 18, 2020 at 17:05
  • i did exactly what they said, but i dont know what it doesnt works on my raspberry pi, maybe it's an iptable problem but actually how you can see in the edit1, my request is redirected, but it give a 302 response Feb 18, 2020 at 18:02
  • @CesarBeltran I suggest following instructions carefully. The "302 response" is Ok.
    – M. Rostami
    Feb 18, 2020 at 18:19
  • im supossed that recive a 204 reponse will display a captif portal righ Feb 18, 2020 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.