Troubleshooting:Nginx Troubleshooting: Difference between revisions
Appearance
Minor update - troubleshooting guide: Nginx Troubleshooting (13 sections) (troubleshooting) |
Major update - troubleshooting guide: Nginx Troubleshooting (23 sections) (troubleshooting) |
||
| Line 1: | Line 1: | ||
This guide covers troubleshooting for Nginx configuration and service issues. | This guide covers troubleshooting for Nginx configuration and service issues. | ||
| Line 31: | Line 29: | ||
=== Nginx Won't Start === | === Nginx Won't Start === | ||
= '''Check status''': = | ==== '''Check status''': ==== | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
systemctl status nginx | systemctl status nginx | ||
</pre> | </pre> | ||
= '''Check logs''': = | == '''Check logs''': == | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
journalctl -u nginx -n 50 | journalctl -u nginx -n 50 | ||
</pre> | </pre> | ||
= '''Test configuration''': = | == '''Test configuration''': == | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
nginx -t | nginx -t | ||
| Line 48: | Line 46: | ||
=== Nginx Reload Fails === | === Nginx Reload Fails === | ||
= '''Test configuration first''': = | ==== '''Test configuration first''': ==== | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
nginx -t | nginx -t | ||
</pre> | </pre> | ||
= '''Check for syntax errors''' in configuration files = | == '''Check for syntax errors''' in configuration files == | ||
= '''Verify file permissions''': = | == '''Verify file permissions''': == | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
ls -la /etc/nginx/sites-enabled/ | ls -la /etc/nginx/sites-enabled/ | ||
| Line 65: | Line 63: | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
= View recent errors = | ==== View recent errors ==== | ||
tail -f /var/log/nginx/error.log | tail -f /var/log/nginx/error.log | ||
= Search for specific errors = | == Search for specific errors == | ||
grep "error" /var/log/nginx/error.log | grep "error" /var/log/nginx/error.log | ||
</pre> | </pre> | ||
| Line 75: | Line 73: | ||
<pre class="lang-bash"> | <pre class="lang-bash"> | ||
= View recent access = | ==== View recent access ==== | ||
tail -f /var/log/nginx/access.log | tail -f /var/log/nginx/access.log | ||
= Analyze traffic = | == Analyze traffic == | ||
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | ||
</pre> | </pre> | ||
Revision as of 13:44, 1 January 2026
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
Related Documentation
- [Adding Services](index.md) - Service configuration
- [Service Management](service-management.md) - Service management