-
-
Notifications
You must be signed in to change notification settings - Fork 349
NUT on Nginx with fcgiwrap
I'm assuming you have Nginx installed and have a working configuration. I'm also assuming you're running Debian or a derivative.
Unlike Apache, Nginx doesn't have built in support for executing CGI scripts, so a helper application is needed to handle dynamic content. In this case, that package is fcgiwrap.
Start by installing the packages.
sudo apt-get update && sudo apt-get install nut-cgi fcgiwrap
Edit the configuration file at /etc/nut/hosts.conf and add the following line (replace cyberpower1 with the friendly name of your UPS). This step is part of the Apache instructions as well.
MONITOR cyberpower1@localhost "CyberPower CP1500PFCLCD"
The HTML files that come from the nut-cgi package have links to /cgi-bin/nut/upsstats.cgi and /cgi-bin/nut/upsset.cgi. We need two locations:
- a location (named /nut) for the HTML files located in /usr/share/nut/www
- a location (named /cgi-bin/) for the CGI files located in the standard directory of /usr/lib
The location block looks like this.
server {
...
location /nut {
alias /usr/share/nut/www/;
try_files $uri $uri/ /index.html;
}
location /cgi-bin/ {
gzip off;
root /usr/lib;
include fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
...
}
Change ownership of the CGI files and start/restart the necessary services.
sudo chown www-data:www-data /usr/lib/cgi-bin/nut/*.cgi
sudo systemctl restart fcgiwrap.service
sudo systemctl restart fcgiwrap.socket
sudo systemctl restart nginx
Then, visit your stats page at http://your_IP/nut
If you want to visit the settings/admin page, you will need to edit the configuration file at /etc/nut/upsset.conf and uncomment the line below. This step is part of the Apache instructions as well.
###I_HAVE_SECURED_MY_CGI_DIRECTORY
https://loganmarchione.com/2017/02/raspberry-pi-ups-monitor-with-nginx-web-monitoring/
Welcome to the Network UPS Tools (NUT) project Wiki, and feel free to contribute tricks and insights.
While there are several good entries in the menu, ones referenced most frequently in issue discussions include:
- Building NUT for in-place upgrades or non-disruptive tests and Using NIT (NUT Integration Test suite) sandbox
- Technicalities: Customizing (NUT) config files and scripts delivered by packaging
- Links to distribution packaging recipes and repository sections
- Troubleshooting
upsdrvctl
drivers not starting ("insufficient permissions on everything") possibly due to nut-driver-enumerator (NDE) services having been there before you with NUT 2.8.x - Changing NUT daemon debug verbosity
- Building NUT integration for Home Assistant
- Running NUT in an LXC container
- Troubleshooting eventual disconnections (Data stale) and CyberPower Systems (CPS) know-how
- NUT for Windows
- NUT HCL and DDL
- Code contributions, PRs, PGP and DCO
- NUT CI farm
Also keep in mind the documentation links from NUT website and the FAQ in particular.