Jump to content

Troubleshooting:Nginx Troubleshooting

From jb-vpn.uk Wiki
Revision as of 13:16, 1 January 2026 by Josh (talk | contribs) (Added troubleshooting guide: Nginx Troubleshooting (troubleshooting))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Nginx Troubleshooting

This guide covers troubleshooting for Nginx configuration and service issues.

Configuration Errors

Syntax Errors

Symptoms: nginx -t fails with syntax errors

Solutions: Check for missing semicolons Verify bracket matching Check for typos in directive names

Duplicate Server Names

Symptoms: Warning about duplicate server_name

Solutions: Check all configuration files in /etc/nginx/sites-enabled/ Remove duplicate server_name entries Ensure only one config per subdomain

Service Issues

Nginx Won't Start

Check status:

   systemctl status nginx

Check logs:

   journalctl -u nginx -n 50

Test configuration:

   nginx -t

Nginx Reload Fails

Test configuration first:

   nginx -t

Check for syntax errors in configuration files

Verify file permissions:

   ls -la /etc/nginx/sites-enabled/

Log Analysis

Error Logs

= View recent errors =
tail -f /var/log/nginx/error.log

= Search for specific errors =
grep "error" /var/log/nginx/error.log

Access Logs

= View recent access =
tail -f /var/log/nginx/access.log

= Analyze traffic =
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn

Common Configuration Issues

SSL Certificate Problems

Verify certificate exists: certbot certificates Check certificate expiration: openssl x509 -in /etc/letsencrypt/live/domain/cert.pem -noout -dates Renew if needed: certbot renew

Proxy Issues

Check proxy_pass URL is correct Verify target service is accessible Check proxy headers are set correctly

[Adding Services](index.md) - Service configuration [Service Management](service-management.md) - Service management