Troubleshooting:Nginx Troubleshooting
Appearance
Note: Public HTTPS on this VPS is handled by Caddy (/etc/caddy/Caddyfile). Use System:Service Management and journalctl -u caddy for edge proxy issues.
This guide covers legacy host Nginx site files and the WebApp stack's internal Nginx container. Host Nginx is not the active edge proxy for *.jb-vpn.uk services.
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
Related Documentation
- [Adding Services](index.md) - Service configuration
- [Service Management](service-management.md) - Service management