Jump to content

Troubleshooting:Nginx Troubleshooting: Difference between revisions

From jb-vpn.uk Wiki
Minor update - troubleshooting guide: Nginx Troubleshooting (13 sections) (troubleshooting)
Updated documentation from markdown files
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
= Nginx Troubleshooting =
'''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 troubleshooting for Nginx configuration and service 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 <code>*.jb-vpn.uk</code> services.


== Configuration Errors ==
== Configuration Errors ==
Line 31: 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 48: 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 65: 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 75: 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>

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
[edit]
  • [Adding Services](index.md) - Service configuration
  • [Service Management](service-management.md) - Service management