Skip to content

About

Nut CGI in a container

Resources

Stars

11 stars

Watchers

1 watching

Forks

Repository files navigation

docker-nut-cgi

A container with the CGI tools of Network UPS Tools and fcgiwrap to be used in conjunction with an nginx container.

Image hosted at: ghcr.io/jchonig/nut-cgi

Many nginx containers are based on alpine which does not have the Nut CGI tools available. This container is based on Ubuntu and installs nut-cgi and fcgiwrap.

Usage

docker-compose

Compatible with docker-compose v3 schemas.

---
version: "3"
services:
  nut-cgi:
    image: ghcr.io/jchonig/nut-cgi
    container_name: nut-cgi
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/London
    volumes:
      - nut-html:/config/www/nut
      - /etc/nut/hosts.conf:/etc/nut/hosts.conf:ro
    expose:
      - 8081
    restart: unless-stopped

  nginx:
    ...
    volumes:
      ...
      - nut-html:/config/www/nut:ro
    restart: unless-stopped
    depends_on:
      - nut-cgi

volumes:
  nut-html:

Parameters

Environment Variables (-e)

Env Function
PUID=1000 for UserID - Set to UID that will run Nginx
PGID=1000 for GroupID - Set to GID that will run Nginx
TZ=UTC Specify a timezone to use EG UTC

Volume Mappings (-v)

Volume Function
/config/www/nut Receives a copy of /usr/share/nut/www for nginx

Application Setup

  • Map a NUT hosts.conf file to /etc/nut/hosts.conf
  • Configure nginx to talk to the nut-cgi container for cgi-bin/nut:
location /nut {
    root /config/www;
    try_files $uri/index.html =404;
}
location /cgi-bin/nut/ {
    gzip off;
    root /usr/lib;

    include /etc/nginx/fastcgi_params;
    fastcgi_pass nut-cgi:8081;
    fastcgi_param SCRIPT_FILENAME /usr/lib/$fastcgi_script_name;
}

Updates and security

  • Renovate opens pull requests for new lsiobase/ubuntu images (pinned by digest, so each rebuild of it is a pull request) and GitHub Actions versions. CI builds those pull requests but doesn't publish an image for Renovate's branches.
  • The weekly build only builds and pushes when the published image has Ubuntu package updates. Run the Build and Push workflow by hand with force to rebuild anyway.
  • A scan runs Trivy daily, and after each build from main, on the published image, and reports fixable HIGH and CRITICAL vulnerabilities in the repository's Security tab. The scan fails while any are found.

About

Nut CGI in a container

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages