When running a tool like NGINX, which generally sits in front of your applications, it’s important to understand how to debug issues. And because you need to see the logs, you have to understand the different NGINX logging mechanisms. In addition to the errors in your application or web s...
We can type the commandnginx -v(lowercase v) in Linux, macOS, and Windows to show the Nginx version currently installed on our system. 1. Check Nginx version The Nginx with a lowercasevoption, thenginx -Vshow the version and then exits. In the below output, Nginx version 1.21.0 is cu...
In this tutorial, we’ll see how to clear the system logs in Ubuntu 20.04. However, the steps described here should be the same on most Linux systems usingsystemd. 2. Logging Mechanism In Linux, applications often place their logs under/var/log. For example, the logs from the NGINX web ...
This section will show you how to get the client IP addresses using a Linux command. The provided method of parsing Nginx access logs can be useful for you if you want to know who has connected to the server or when you want to check out the IP addresses associated with the known troub...
Logs are very important in a system to monitor the activities of an application as they provide you with useful debugging information and enable you to analyze all aspects of a web server. Nginx also maintains events like your web site visitors, encounte
Here's a simple Python script to parse Nginx logs and count unique IP addresses: with open('/var/log/nginx/access.log', 'r') as file: unique_ips = set() for line in file: ip = line.split()[0] unique_ips.add(ip) print(f"Unique IP addresses: {len(unique_ips)}") ...
Nginx does not provide tools to manage log files, but it does include mechanisms to assist with log rotation. Manual Log Rotation To manually rotate your logs, you can create a script to rotate them. For example, move the current log to a new file for archiving. A common sche...
1. Enable root privileges using thesudo commandor switching to root withsu. 2. Run thecd commandto navigate to the/var/logdirectory: cd /var/log 3. To view the logs, type thels command: sudo ls The command displays all Linux log files, such askern.logandboot.log. These files contain...
The image above shows a “502 Bad Gateway NGINX” error from a server using NGINX as a reverse proxy, which is a very common web-server setup. The error page may be further customized by some hosting providers. Below you can see an example of a customized “502 Bad Gateway” Error page...
After installation, ensure NGINX is running correctly. Check the NGINX service status with the following: systemctl status nginx Example of Nginx server status OK on Debian Linux NGINX operates correctly if the output shows “active (running).” If not, the output will detail the error for trou...