From 537f455e10468b066f49668d03ff8f8698c44c98 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Thu, 24 Sep 2026 13:27:08 +0500 Subject: [PATCH] instruvtcion to route 8000 to 80 via apache --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 95d9539..40334fb 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,26 @@ journalctl -u jsonnutserver.service -f curl 'http://localhost:8000/jsonstatus?=nutdev1@localhost' ``` +## Serve through Apache (optional) + +To expose `/jsonstatus` on an existing Apache site, proxy it to the local server. +Consider setting `LISTEN_HOST=127.0.0.1` (see above) so port 8000 is only +reachable through Apache. + +```bash +sudo a2enmod proxy proxy_http +sudo tee /etc/apache2/conf-available/nut-json.conf > /dev/null <<'EOF' +ProxyPass /jsonstatus http://127.0.0.1:8000/jsonstatus +ProxyPassReverse /jsonstatus http://127.0.0.1:8000/jsonstatus +EOF +sudo a2enconf nut-json +sudo apachectl configtest && sudo systemctl restart apache2 +``` + +```bash +curl 'http://localhost/jsonstatus?=nutdev1@localhost' +``` + ## Update ```bash @@ -90,3 +110,11 @@ sudo rm /etc/systemd/system/jsonnutserver.service sudo systemctl daemon-reload sudo rm -r /opt/jsonnutserver ``` + +If you set up the Apache proxy: + +```bash +sudo a2disconf nut-json +sudo rm /etc/apache2/conf-available/nut-json.conf +sudo systemctl reload apache2 +```