To deal with the Android captive portal detection for my specific setup, I need to return an HTTP status code 204 whenever I get a GET request for /generate_204
. I currently use uhttpd as my webserver, so I'm wondering whether this is possible to do with this server.
My current understanding: I need to write myself a CGI (or PHP or Lua) script that returns something like
Status: 204 No Result
The question I have is how I can configure uhttpd to forward requests to /generate_204
to CGI or PHP or Lua, since that neither has a prefix nor a file-extension that I can match for this purpose.
Unfortunately @HBruijn's quite clever idea of simply making
/generate_204
a directory rather than a file and then using that as thecgi_prefix
with anindex.cgi
-file inside it as theindex_page
, only works partly. When I open/generate_204
from the browser myself, it does exactly what I wanted, but only after first returning a redirect to/generate_204/
, which the Android captive portal detection explicitly ignores. So, unfortunately this solution doesn't solve my problem.Here's the hack-job I've come up with that does seem to work:
Simply don't have a
/generate_204
file at all and instead create a CGI-script incgi-bin
that handles all erroneous requests that looks like this:Then simply add the following to
/etc/config/uhttpd
:(adjusting file and folder names as needed)
This is definitely not the cleanest solution, and in case there's a way to prevent the redirect and make @HBruijn's idea work, I'll leave the question open for now, since I'd much prefer that.