Nginx Reverse-Proxy Advanced Logging (Go Access for Nginx)

Nginx Reverse-Proxy Advanced Logging (Go Access for Nginx)

Nginx Reverse-Proxy Advanced Logging (Go Access for Nginx)
go-access Makes Utterly Beautiful Logging Stats - For Free.
  • GoAccess can create a beautiful traffic dashboards  from  your nginx-proxy logs.
  • Because nginx-proxy runs inside  a container we will need a shared volume that go-access can see nginx-proxy logs.

An example image will look as:

If you need a review on installing Docker:

bash: script: docker installation
In this quick guide we go over installation of docker in the Ubuntu type environment:

Make a directory with a docker-compose.yml inside it as follows:

version: '3.3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: proxy-manager
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    networks:
      - nginx-proxy
  goaccess:
    image: xavierh/goaccess-for-nginxproxymanager:latest
    container_name: goaccess
    restart: unless-stopped
    ports:
      - '7880:7880'  # GoAccess dashboard
    environment:
      - TZ=UTC  # Adjust to your timezone
      - SKIP_ARCHIVED_LOGS=False
      - BASIC_AUTH=False  # Enable and set USERNAME/PASSWORD if desired
      - LOG_TYPE=NPM  # For NGINX Proxy Manager format
      - HTML_REFRESH=60  # Refresh report every 60 seconds
    volumes:
      - ./data/logs:/opt/log:ro  # Mount host logs path (read-only)
volumes:
  data:
  letsencrypt:
networks:
  nginx-proxy:
    external:
      name: nginx-proxy-network
  • The volumes are key, by adding:
- .data/logs:/opt/log:ro

This is giving goaccess-for-nginxproxymanager access to the nginx proxy logs.

  • The other key is:
LOG_TYPE=NPM  # For NGINX Proxy Manager format

To get inside your running nginx-proxy container we use:

docker exec -it proxy_container /bin/bash

Once you are in you will be presented with as the following:

The logs live in /data/logs:

By letting go-access access them they will automatically be read and processed.

In order for go-access to work it must have access to websocks. In your nginx-proxy you must turn on:

Linux Rocks Every Day