Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Analyze Nginx Logs with GoAccess

The Nginx access log records every request your website receives, but reading it manually means going through thousands of lines. GoAccess turns it into a report showing visitors, most-viewed pages, error codes, browsers, and the IP addresses that make the most requests. It doesn’t require JavaScript on your website or external services—it works directly with the log on your server.

1. Install it

sudo apt updatesudo apt install -y goaccess

2. First report at the terminal

The default Nginx log format is COMBINED:

sudo goaccess /var/log/nginx/access.log --log-format=COMBINED

Use Tab to move between panels, use Intro to open one, and use q to exit.

3. What to Look at First

  • Not Found (404): broken links on your website and, above all, automated scans. URLs such as /.env, /wp-login.php on a non-WordPress website, or /phpmyadmin are bots searching for vulnerabilities.
  • Visitor Hostnames and IPs: A single IP address generating thousands of requests is usually a bot or an abuse case. It should be restricted or blocked.
  • HTTP Status Codes: Many 5xx errors indicate that the problem lies with your application, not with what visitors are requesting.
  • Requested Files: the pages that put the most load on your server and benefit the most from caching.

4. Include the rotated logs

logrotate stores previous days' logs in access.log.1, access.log.2.gz, and so on. To view several weeks' worth, pass them all at once; zcat -f reads both compressed and uncompressed files:

sudo zcat -f /var/log/nginx/access.log* | goaccess - --log-format=COMBINED

5. HTML Report

The HTML report can be opened in a browser and shared. Generate it in a private folder in your user account, outside the public website folder and /tmp, using --ignore-crawlers so that visits from search engines aren't counted in the report:

mkdir -p ~/informes && chmod 700 ~/informes && \  sudo zcat -f /var/log/nginx/access.log* | goaccess - --log-format=COMBINED --ignore-crawlers -o ~/informes/informe.html

The easiest way is to download it using this command, which you run on your PC:

scp [email protected]:informes/informe.html .

If you prefer to view it in a browser, publish it to a password-protected location. Create the user with htpasswd (package apache2-utils), generate the report in /var/www/informes/index.html, and add the following to the block server:

location /informes/ {    alias /var/www/informes/;    auth_basic "Informes";    auth_basic_user_file /etc/nginx/.htpasswd-informes;}

Don't leave it public without a password: the report shows IP addresses, internal routes, and details about your traffic.

Tips

  • Privacy: With --anonymize-ip, GoAccess hides the last part of each IP address. Use this if you plan to share the report.
  • Behind Cloudflare: If the log records the proxy's IP addresses, first configure the realip module in Nginx to log the visitors' IP addresses.
  • Large logs: With months' worth of logs, GoAccess uses a lot of memory. Analyze the data by week if your VPS is running low on resources.

ext step

If the report shows that your website is receiving more traffic than your server can handle, choose a Cloud VPS with more resources and enable caching for the most frequently requested pages.

Related guides