generate_204 is not accepted by all Android devices.
Opened this issue · 1 comments
Official answer to /generate_204
curl -v http://connectivitycheck.gstatic.com/generate_204
- Trying 2a00:1450:4001:80b::2003...
- TCP_NODELAY set
- Connected to connectivitycheck.gstatic.com (2a00:1450:4001:80b::2003) port 80 (#0)
GET /generate_204 HTTP/1.1
Host: connectivitycheck.gstatic.com
User-Agent: curl/7.60.0
Accept: /
HTTP/1.1 204 No Content
Content-Length: 0
Date: Tue, 17 Jul 2018 18:59:28 GMT
What the conversation looks on PirateBox:
GET /generate_204 HTTP/1.1
User-Agent: Dalvik/2.1.0 (Linux; U; Android 7.0; Moto G (4) Build/NPJS25.93-14.7-8)
Host: connectivitycheck.gstatic.com
Connection: Keep-Alive
Accept-Encoding: gzip
HTTP/1.1 204 No Content
X-Powered-By: PHP/7.2.5
Content-type: text/html; charset=UTF-8
Cache-Control: max-age=60, must-revalidate, no-store, no-cache, public
Date: Tue, 24 Apr 2018 00:39:16 GMT
Server: lighttpd/1.4.49
I guess we need to avoid:
X-Powered-By: PHP/7.2.5
Content-type: text/html; charset=UTF-8
Cache-Control: max-age=60, must-revalidate, no-store, no-cache, public
Server: lighttpd/1.4.49
Ok, I am getting pretty close, but only on the latest lighttpd version.
-
change /etc/php/php.ini expose option to Off
sudo sed -i -e 's|expose_php = On|expose_php = Off|g' /etc/php/php.ini
-
Change /opt/piratebox/www/generate_204 to:
<?php
// Return an empty page to fake a working internet connection for
// android
ini_set("expose_php","off");
header('Content-Type:', true);
http_response_code(204);
?>
- Change /opt/piratebox/conf/lighttpd/fastcgi-php-generate203.conf to
$HTTP["url"] =~ "^/generate_204$" {
fastcgi.server = (
"" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1
))
)
setenv.set-response-header = ( "Content-Length" => "0" )
server.tag =""
mimetype.use-xattr = "disable"
}
The result renders "only"
$ curl -i http://127.0.0.1:8001/generate_204
HTTP/1.1 204 No Content
Date: Tue, 17 Jul 2018 19:40:16 GMT