Skip to content

scph7502c/nginx-log-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Nginx Log Parser (WIP)

This repository is a work in progress project focused on parsing and analyzing server logs with Python.
The first script included here works with Nginx access logs, but the repository will be extended with additional tools and parsers in the future.


πŸš€ Current Features

  • Read Nginx access log line by line
  • Extract basic fields:
    • IP address
    • HTTP status code
  • Load configuration from a .env file (e.g., log file path)

πŸ› οΈ Technologies

  • Python 3.x
  • Built-in modules: os, pathlib
  • Optional: python-dotenv – for loading .env files

πŸ“‚ Repository Structure

.
β”œβ”€β”€ nginx_log_parser.py   # current script (WIP)
β”œβ”€β”€ .env                  # config file with log file path (example only)
β”œβ”€β”€ sample.access.log     # sample Nginx log file (for testing)
└── README.md             # documentation

βš™οΈ Setup

  1. Create a .env file:
    NGINX_LOG_FILE=./sample.access.log
    
  2. Install dependencies:

python nginx_log_parser.py

  1. Run the script: python nginx_log_parser.py

Example Output IP: 182.44.67.97, Status: 301 IP: 43.157.179.227, Status: 200 ...

🎯 Project Goal

The purpose of this repository is to:

Practice Python file handling, text processing, and regex

Build tools for log parsing and analysis

Expand into a collection of scripts that demonstrate real-world Python use cases for system administration and cybersecurity

πŸ“Œ Roadmap

Basic Nginx log reader (current)

Extend parsing (date, request, user agent, referrer, etc.)

Add filtering and statistics (e.g., 404 errors, most common IPs)

Implement support for other log formats (Apache, system logs, etc.)

Provide CSV/JSON export functionality

About

Python scripts for parsing and analyzing Nginx access logs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages