Sign inSign up

vincentzyu233/nginx-report

By vincentzyu233

•Updated 5 months ago

Nginx access log statistics tool

Image
0

905

vincentzyu233/nginx-report repository overview

nginx-report

English⁠ | 中文⁠

⁠Nginx Access Statistics

Nginx access log statistics tool that queries visitor IP locations and displays a leaderboard.

GitHub Gitee Docker Hub

Docker Image Pulls Docker Image Build and Publish


⁠Preview

⁠WebUI Preview

doc/preview-images/nginx-report-py-version-preview.png


⁠Python Version

⁠Quick Start
# clone repo
git clone https://github.com/VincentZyuApps/nginx-report
# or from Gitee mirror
git clone https://gitee.com/vincent-zyu/nginx-report.git
cd py

# create virtual environment using uv (recommended)
# https://docs.astral.sh/uv/getting-started/installation/
# https://gitee.com/wangnov/uv-custom/releases
uv venv --python 3.13
# install dependencies
uv pip install -r requirements.txt
# run
uv run python main.py

Access the service at http://{your_ip}:60418

⁠Configuration

Edit paths in main.py:

LOG_DIR = "/var/log/nginx"  # Nginx log directory (supports access.log and rotated logs)
DB_FILE = "data/data.db"    # SQLite database path

⁠Go Version

⁠Docker
# basic run (data will be lost when container is removed)
docker run -d --name nginx-report -p 60419:60419 -v /var/log/nginx:/var/log/nginx:ro vincentzyu233/nginx-report:latest
# 大陆用户可以使用 DaoCloud 镜像:
docker run -d --name nginx-report -p 60419:60419 -v /var/log/nginx:/var/log/nginx:ro m.daocloud.io/docker.io/vincentzyu233/nginx-report:latest 
# with data persistence
docker run -d --name nginx-report -p 60419:60419 -v /var/log/nginx:/var/log/nginx:ro -v ./data:/app/data vincentzyu233/nginx-report:latest

then open http://{your_ip}:60419 to access webui~

Update to latest image:

docker pull vincentzyu233/nginx-report:latest
docker stop nginx-report && docker rm nginx-report
# docker rmi vincentzyu233/nginx-report:latest # optional: delete old image
# rerun, use same arg as above
docker run -d --name nginx-report -p 60419:60419 -v /var/log/nginx:/var/log/nginx:ro vincentzyu233/nginx-report:latest
docker image prune -f

manually configure docker image registry mirror:

nano /etc/docker/daemon.json
{ "registry-mirrors": ["https://docker.1ms.run"] }
systemctl restart docker
⁠Environment Variables

For Docker, use -v to persist data instead of environment variables.

VariableDefaultDescription
DB_PATHdata/data.dbSQLite database path (container internal path)
⁠Build from Source
cd go

# download dependencies
go mod download

# build
CGO_ENABLED=1 go build -o server .

# run
./server
# with data persistence, pass env variable:
DB_PATH=/custom/path/data.db ./server
⁠Docker Compose
nano ./docker-compose.yml
version: '3'
services:
  nginx-report:
    container_name: nginx-report
    image: vincentzyu233/nginx-report:latest
    ports:
      - "60419:60419"
    volumes:
      - /var/log/nginx:/var/log/nginx:ro
      # - ./data:/app/data  # uncomment to persist database
    restart: unless-stopped
# start
docker compose up -d
# view logs
docker compose logs -f

Update to latest image:

# update to latest image: pull latest, then recreate & start container with new config/image (if updated)
docker compose pull && docker compose up -d
docker image prune -f

Tag summary

Content type

Image

Digest

sha256:7476eefcb…

Size

53.9 MB

Last updated

5 months ago

docker pull vincentzyu233/nginx-report