Android Phone的Captive Portal未弹出 [英] Captive Portal for Android Phone did not pop up

查看:72
本文介绍了Android Phone的Captive Portal未弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用hostapd,dnsmasq和apache2在Raspberry Pi 3B +上通过自带门户实施wifi热点,在实施此项目之前,我从未与wifi网络保持联系.因此,我搜索了很多关于如何实现的文章.

I used hostapd, dnsmasq and apache2 for implementing the wifi-hotspot with captive portal on my Raspberry Pi 3B+, before I implement this project, I have never get in touch with wifi networks. Hence I search a lot of post on how to implement one.

以下是我使用的配置:

/etc/apache/apache.conf:

/etc/apache/apache.conf:

# Apple
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^CaptiveNetworkSupport(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^192.168.0.200$
RewriteRule ^(.*)$ http://192.168.0.200/index.html [L,R=302]

# Android
RedirectMatch 302 /generate_204 http://192.168.0.200/index.html

# All
RewriteCond %{REQUEST_URI} !=/index.html
RewriteRule ^(.*)$ http://192.168.0.200/index.html [L]

# 404 Redirect
ErrorDocument 404 http://192.168.0.200/index.html

/etc/dnsmasq.conf:

/etc/dnsmasq.conf:

interface=wlan0
dhcp-range=192.168.0.201,192.168.0.210,255.255.255.0,24h
address=/#/192.168.0.200

我使用Sony H4133,HUAWEI RNE-22,Redmi Note3,Samsung Galaxy S8 +,Samsung Galaxy Tab S测试了该门户.只有索尼的一部像魅力一样.Tab S可以弹出一个通知,但是当我单击它时,它会将我发送到google.com,但不会将我发送到我的门户.虽然其他人甚至没有显示弹出窗口.

I used Sony H4133, HUAWEI RNE-22, Redmi Note3, Samsung Galaxy S8+, Samsung Galaxy Tab S to test the portal. Only the Sony one work like a charm. Tab S can pop up a notification but when I click on it, it send me to google.com but not my portal. While others didn't even show the pop up.

我检查了access.log,发现/generate_204确实是302重定向到我的页面并返回了200代码.根据我的研究,除204以外的任何代码返回都应显示弹出窗口,但是为什么这里不是这种情况?

I checked the access.log and find that the /generate_204 indeed 302 redirect to my page and return a 200 code. According to my research, any code return other than 204 should show up the pop up, but why it is not the case here?

access.log:

access.log:

192.168.0.204 - - [04/Jan/2020:12:20:10 +0800] "GET /index.html HTTP/1.1" 200 899 "-" "MQ 3.3.8/3.0 (Android 6.0.1) Xiaomi Redmi Note 3"
192.168.0.204 - - [04/Jan/2020:12:20:11 +0800] "GET /generate_204 HTTP/1.1" 302 561 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:15 +0800] "POST /getconfig HTTP/1.1" 302 531 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:15 +0800] "GET /index.html HTTP/1.1" 200 862 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:15 +0800] "POST /mistats/v2 HTTP/1.1" 302 531 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:15 +0800] "GET /index.html HTTP/1.1" 200 862 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:20 +0800] "POST /mistats/v2 HTTP/1.1" 302 531 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"
192.168.0.204 - - [04/Jan/2020:12:20:20 +0800] "GET /index.html HTTP/1.1" 200 862 "-" "Dalvik/2.1.0 (Linux; U; Android 6.0.1; Redmi Note 3 MIUI/V10.2.1.0.MHOMIXM)"



192.168.0.205 - - [04/Jan/2020:12:23:31 +0800] "GET /generate_204 HTTP/1.1" 302 570 "-" "Dalvik/2.1.0 (Linux; U; Android 8.0.0; RNE-L22 Build/HUAWEIRNE-L22)"
192.168.0.205 - - [04/Jan/2020:12:23:31 +0800] "GET /generate_204 HTTP/1.1" 302 560 "-" "Dalvik/2.1.0 (Linux; U; Android 8.0.0; RNE-L22 Build/HUAWEIRNE-L22)"
192.168.0.205 - - [04/Jan/2020:12:23:31 +0800] "GET /generate_204 HTTP/1.1" 302 560 "-" "Dalvik/2.1.0 (Linux; U; Android 8.0.0; RNE-L22 Build/HUAWEIRNE-L22)"
192.168.0.205 - - [04/Jan/2020:12:23:44 +0800] "GET /generate_204 HTTP/1.1" 302 570 "-" "Dalvik/2.1.0 (Linux; U; Android 8.0.0; RNE-L22 Build/HUAWEIRNE-L22)"
192.168.0.205 - - [04/Jan/2020:12:23:56 +0800] "GET /generate_204 HTTP/1.1" 302 570 "-" "Dalvik/2.1.0 (Linux; U; Android 8.0.0; RNE-L22 Build/HUAWEIRNE-L22)"

推荐答案

apache.conf 是您的问题.以另一种方式配置Apache2.
每个操作系统都有其自己的不同方法来检测Internet访问.

apache.conf is your problem. Config Apache2 in another way.
Every operating system has its own different way of detecting Internet access.

机制基本上是这样的:

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  

每个设备(也是Android不同制造商)的行为也有所不同.例如,查看以下列表:

Each device, also Android different manufactures, behaves differently. For example, look at this list:

xperia z5:
connectivitycheck.gstatic.com:80
clients3.google.com:80
---------------------
galaxy j3 2016:
172.217.21.14:80    connectivitycheck.android.com
---------------------
galaxy j7 2015:
172.16.98.10:80
connectivitycheck.gstatic.com:80
---------------------
galaxy note4:
nothing!
---------------------
ios 11:
captive.apple.com/hotspot-detect.html
---------------------
windows 10:
www.msftconnecttest.com

我建议为每个设备/制造制作另一个apache配置文件.

I suggest make another apache config file for each device/manufacture.

在apache中为android创建目录

Create a directory for android in apache

cd /var/www/html/
sudo mkdir android 

创建一个简单的index.html文件,该文件将出现在android设备的初始页面上.

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

在nano(或您喜欢的文本编辑器)中创建 android.conf ,然后复制以下代码以为Android设备创建重定向规则".

Create android.conf in nano (or your favorite text editor) and copy the following code to create a "redirection rule" for Android devices.

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

放入以下行:

<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

</VirtualHost>

保存文件并退出.

完成.按照其他设备的步骤进行操作.另外,请查看此链接以获取更多信息.

Done. Follow the procedure for other devices. Also, check this link out to get more information.

这篇关于Android Phone的Captive Portal未弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆