Jump to content

Troubleshooting:Nginx Troubleshooting: Difference between revisions

From jb-vpn.uk Wiki
Added troubleshooting guide: Nginx Troubleshooting (troubleshooting)
 
Minor update - troubleshooting guide: Nginx Troubleshooting (13 sections) (troubleshooting)
Line 10: Line 10:


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


=== Duplicate Server Names ===
=== Duplicate Server Names ===
Line 19: Line 21:


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


== Service Issues ==
== Service Issues ==
Line 82: Line 86:
=== SSL Certificate Problems ===
=== SSL Certificate Problems ===


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


=== Proxy Issues ===
=== Proxy Issues ===


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


== Related Documentation ==
== Related Documentation ==


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


[[Category:Documentation]]
[[Category:Documentation]]
[[Category:Documentation/Troubleshooting]]
[[Category:Documentation/Troubleshooting]]

Revision as of 13:28, 1 January 2026

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