Bunn / PiStats

macOS app to visualize Pi-hole information
BSD 2-Clause "Simplified" License
371 stars 12 forks source link

Pi Stats cannot connect to Pi-hole #22

Closed miszterx closed 3 years ago

miszterx commented 4 years ago

Hi, I have the latest 2.2.0 Pi-Stats on MacOs. On the server side I have: Pi-hole v5.1.2 Web Interface v5.1.1 FTL v5.2.

I get the API Token. Took in the necessary field in the Pi-Stats and I just got red icon. On the server side I have checked the nginx log and I can see:

I can see just HTTP code 400. Can you help me with this? Thanks!

Bunn commented 4 years ago

What happens if you run the same request on cURL?

miszterx commented 4 years ago

Hi, With curl it woks fine:

curl "https://pihole/admin/api.php?auth=xxxxxxxxxxx&enable="

{"status":"enabled"}

curl "https://pihole.xorp.hu/admin/api.php?"

{"domains_being_blocked":337448,"dns_queries_today":10389,"ads_blocked_today":1817,"ads_percentage_today":17.489653,"unique_domains":2254,"queries_forwarded":7110,"queries_cached":1462,"clients_ever_seen":9,"unique_clients":9,"dns_queries_all_types":10389,"reply_NODATA":132,"reply_NXDOMAIN":111,"reply_CNAME":975,"reply_IP":1976,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1598753399,"relative":{"days":2,"hours":7,"minutes":11}}}%

But if the Pi Stats try the same:

I can get 400

Any idea?

Bunn commented 4 years ago

@miszterx if you don't mind can you post a screenshot of the Pi Stats preferences window? I'm interested in how you configured the URL, is it https://pihole.xorp.hu?

miszterx commented 4 years ago

Sure. Here it is:

Screenshot 2020-09-01 at 19 46 54

I needed to add the port for https. Without the port it wanted to go on port 80 by default. With :443 it goes to the proper HTTPS site definition, but with the result what I reported above.

Bunn commented 3 years ago

It seems the issue is when the app tries to access an external URL with HTTPS. I'm going to add a flag when setting up the pi-hole asking the user if it's http or https, that the app will know what to do.

miszterx commented 3 years ago

Perfect! Thanks. I am glad that you could reproduce it. Looking forward to test the new version.

Bunn commented 3 years ago

@miszterx I've added an option for you to configure your pi-hole as either HTTP or HTTPS.

image

I'm attaching the beta version here, if you can give it a try I'd appreciate :)

PiStatsBeta.zip

miszterx commented 3 years ago

Works fine! Thanks!

Screenshot 2020-10-08 at 8 12 42