Define log_format in nginx.conf with variables like $request_time (total request time), $upstream_connect_time (time to connect to Node.js), and $upstream_response_time (Node.js response time). Then use access_log /path/to/log main; to apply it.
Nginx Logging and Debugging Access Logs, Error Logs, and Troubleshooting
How do I create a custom Nginx log format?
The answer
More FAQs in Nginx Logging and Debugging Access Logs, Error Logs, and Troubleshooting
Access logs are at /var/log/nginx/access.log (every HTTP request) and error logs are at /var/log/nginx/error.log (errors and warnings). View in real-time with sudo tail -f /var/log/nginx/access.log or /var/log/nginx/error.log.
Check sudo tail -20 /var/log/nginx/error.log for the error cause. Verify Node.js is running with pm2 status. Check that the proxy_pass port matches the Node.js port. Restart both Nginx and PM2 if needed.
Use awk to extract the URL field and count: sudo awk '{print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20. This shows the top 20 most requested URLs with request counts.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.