https://github.com/geoffdutton/node-pi-hole-api
https://github.com/geoffdutton/node-pi-hole-api
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/geoffdutton/node-pi-hole-api
- Owner: geoffdutton
- License: apache-2.0
- Created: 2018-12-29T18:13:44.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2021-07-06T23:21:50.000Z (almost 5 years ago)
- Last Synced: 2025-01-20T11:13:00.373Z (over 1 year ago)
- Language: JavaScript
- Size: 214 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-pi-hole-api
[](https://travis-ci.org/geoffdutton/node-pi-hole-api)
[](https://coveralls.io/github/geoffdutton/node-pi-hole-api?branch=develop)
[](https://standardjs.com)
[](https://david-dm.org/geoffdutton/node-pi-hole-api)
[Pi-hole](https://github.com/pi-hole/pi-hole) An updated API server written with Node.JS
## Install
- Install Node 8+
- https://github.com/creationix/nvm
- `curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash`
- `nvm install 8`
- `npm install --production`
- or use `yarn` becuase it is much faster
- `npm start`
- A local server will be started on port 3000
- `curl http://localhost:3000/admin/api.php?summary` to get summary
## Integrate with existing pi-hole admin panel
Follow [this guide](https://github.com/pi-hole/pi-hole/wiki/Nginx-configuration-instead-of-the-default-lighttpd-and-php-cgi-option) to setup nginx server
and use this nginx config in order to proxy requests to `/admin/api.php` to our node server
```
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
server_name _;
autoindex off;
location / {
expires max;
return 204 'pixel';
}
location /admin {
root /var/www/html;
index index.php;
auth_basic "Restricted"; #For Basic Auth
auth_basic_user_file /etc/nginx/.htpasswd; #For Basic Auth
}
location /api {
proxy_pass http://localhost:3000;
}
location = /admin/api.php {
proxy_pass http://localhost:3000;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
```
## Why
I wanted to take a crack at porting the pi-hole PHP server side code to Node JS.
Major credit goes to: [xlc/pi-hole-api](https://github.com/xlc/pi-hole-api). This is an updated version of that.
## Development Tips
If you have the `pihole-FTL` service running on your Raspberry-PI, you can forward that port via SSH:
```bash
ssh -L 4711:localhost:4711 user@ssh-host
```