Captive-Portal icon indicating copy to clipboard operation
Captive-Portal copied to clipboard

Keep connected for a local service?

Open thetechknight opened this issue 4 years ago • 8 comments

The captive portal is working great, but the reason I need the captive portal is so the web page will pop up and redirect the user to access a locally hosted service.

Trouble is, when a phone is on the captive portal page, it will only ever load that page. it wont load any other resource or even resolve the DNS thats on the PI.

I dont understand why this is happening.

any ideas?

thetechknight avatar Apr 22 '20 16:04 thetechknight

This captive portal redirect users to index.php that is hosted from nginx weserver. You can replace it with any page with hyperlinks and images and reconfigure nginx if you need to. I use it that way and it works fine. Can you describe what is happening in more details? Did you replace index.php?

23ewrdtf avatar Apr 22 '20 16:04 23ewrdtf

Well I am trying to use a webapp framework that I wrote, which runs on port 51042. Requires HTML5, canvases, etc...

the default nginx pops up sure. but if I say go to Chrome and navigate to hotspot.localnet instead from there, it never loads. It tries to use the mobile internet instead.

thetechknight avatar Apr 22 '20 17:04 thetechknight

Oh, I also lose DNS for the entire system, so after the portal installed, I cant use apt-get anymore.

thetechknight avatar Apr 22 '20 17:04 thetechknight

Well, the idea behind this project was to solve a specific issue for my own project and I was fed up with complexity of other captive portals so I wrote this. This captive portal can be used as a template to modify for other projects.

Do you run that webapp from Captive Portal nginx ?

There is an iptables rule to forward traffic to 192.168.24.1:80 so this might cause issues too.

This script needs an update to be honest and android developer to understand the android logic.

23ewrdtf avatar Apr 22 '20 17:04 23ewrdtf

Well its not going to work anyways, becuase sadly it appears that Websockets dont work behind a "captive portal" browser page. Since my app requires that, it just throws an error.

but I was able to get it to redirect

thetechknight avatar Apr 22 '20 17:04 thetechknight

Yes that another issue. One way to fix it is to get captive portal to allow traffic after you click some button but I was having troubles figuring that out.

23ewrdtf avatar Apr 22 '20 18:04 23ewrdtf

Were you ever able to figure out how to include a button that allows traffic? It would be nice to see some code for having a 'Connect' button that resolves the captive portal needs and connects to the network

hill-spatiam avatar Jan 24 '21 19:01 hill-spatiam

Hi, No, I didn't have time to look into that, and I don't think I will in the near future.

Most likely I would have to rewrite the whole thing to use iptables to block/allow traffic. Similar to those: https://andrewwippler.com/2016/03/11/wifi-captive-portal/ or https://wiki.andybev.com/doku.php?id=using_iptables_and_php_to_create_a_captive_portal

23ewrdtf avatar Jan 28 '21 11:01 23ewrdtf