https://github.com/waliot/logged-nginx
The same NGINX but with logs compression, rotation and retention.
https://github.com/waliot/logged-nginx
docker hacktoberfest hacktoberfest-accepted logging nginx nginx-docker nginx-log nginx-logs
Last synced: about 2 months ago
JSON representation
The same NGINX but with logs compression, rotation and retention.
- Host: GitHub
- URL: https://github.com/waliot/logged-nginx
- Owner: waliot
- License: mit
- Created: 2021-05-21T18:59:31.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-30T06:49:56.000Z (over 2 years ago)
- Last Synced: 2025-03-28T21:14:38.103Z (about 1 year ago)
- Topics: docker, hacktoberfest, hacktoberfest-accepted, logging, nginx, nginx-docker, nginx-log, nginx-logs
- Language: Shell
- Homepage: https://hub.docker.com/r/waliot/logged-nginx
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logged NGINX
The same `NGINX` but with logs compression, rotation and retention.
Every midnight new access and error log files start, the previous day's logs will be compressed.
All compressed logs older than one week will be deleted.
## Getting started
All logs are stored in the directory `/var/log/nginx/`.
* `/var/log/nginx/access.log` - current access logs
* `/var/log/nginx/error.log` - current error logs
* `/var/log/nginx/job.log` - logs of the cron job
* `/var/log/nginx/archive/` - directory with compressed logs
## Running via Docker
### Start with `docker run`
```bash
$ docker build -t logged-nginx .
$ docker volume create nginx_log
$ docker run --name logged-nginx \
--restart unless-stopped \
-v $(pwd)/nginx.conf:/etc/nginx/nginx.conf \
-v nginx_log:/var/log/nginx \
-p 80:80 \
-d logged-nginx:latest
```
### Start with `docker-compose`
```bash
$ docker-compose build
$ docker-compose up
```
### Some useful stuff
Check the `nginx` is working:
```bash
$ curl -X GET localhost:80
> Hello, World!
```
Show the cron job logs:
```bash
$ docker exec logged-nginx tail /var/log/nginx/job.log
```
Search with `grep` in today's access logs:
```bash
$ docker exec logged-nginx grep '"GET / HTTP/1.1" 200' /var/log/nginx/access.log
```
Search with `zgrep` in all archived logs:
```bash
$ docker exec logged-nginx bash -c 'find /var/log/nginx/archive/*.log.gz | xargs zgrep "http://localhost/"'
```