Troubleshooting:Nginx Troubleshooting: Difference between revisions
Appearance
Added troubleshooting guide: Nginx Troubleshooting (troubleshooting) |
Updated documentation from markdown files |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
'''Note:''' Public HTTPS on this VPS is handled by '''Caddy''' (<code>/etc/caddy/Caddyfile</code>). Use [[System:Service Management]] and <code>journalctl -u caddy</code> for edge proxy issues. | |||
This guide covers | 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 <code>*.jb-vpn.uk</code> services. | ||
== Configuration Errors == | == Configuration Errors == | ||
| Line 10: | Line 10: | ||
'''Solutions''': | '''Solutions''': | ||
* Check for missing semicolons | |||
* 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> | |||
* Remove duplicate server_name entries | |||
* Ensure only one config per subdomain | |||
== Service Issues == | == Service Issues == | ||
| Line 27: | Line 31: | ||
=== 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 44: | Line 48: | ||
=== 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 61: | Line 65: | ||
<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 71: | Line 75: | ||
<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> | ||
| Line 82: | Line 86: | ||
=== SSL Certificate Problems === | === SSL Certificate Problems === | ||
* 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> | |||
=== Proxy Issues === | === Proxy Issues === | ||
* Check proxy_pass URL is correct | |||
* Verify target service is accessible | |||
* Check proxy headers are set correctly | |||
== Related Documentation == | == Related Documentation == | ||
* [Adding Services](index.md) - Service configuration | |||
* [Service Management](service-management.md) - Service management | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Documentation/Troubleshooting]] | [[Category:Documentation/Troubleshooting]] | ||
Latest revision as of 14:04, 16 May 2026
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
[edit]Syntax Errors
[edit]Symptoms: nginx -t fails with syntax errors
Solutions:
- Check for missing semicolons
- Verify bracket matching
- Check for typos in directive names
Duplicate Server Names
[edit]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
[edit]Nginx Won't Start
[edit]Check status:
[edit]systemctl status nginx
Check logs:
[edit]journalctl -u nginx -n 50
Test configuration:
[edit]nginx -t
Nginx Reload Fails
[edit]Test configuration first:
[edit]nginx -t
Check for syntax errors in configuration files
[edit]Verify file permissions:
[edit]ls -la /etc/nginx/sites-enabled/
Log Analysis
[edit]Error Logs
[edit]==== View recent errors ==== tail -f /var/log/nginx/error.log == Search for specific errors == grep "error" /var/log/nginx/error.log
Access Logs
[edit]==== 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
[edit]SSL Certificate Problems
[edit]- 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
[edit]- Check proxy_pass URL is correct
- Verify target service is accessible
- Check proxy headers are set correctly
Related Documentation
[edit]- [Adding Services](index.md) - Service configuration
- [Service Management](service-management.md) - Service management