GoAdmio

checknginx

Test the Nginx configuration and remove the virtual host of any domain whose Let's Encrypt certificate is missing, then rebuild the configuration

On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also


Overview

Nginx refuses to start or reload when a virtual host points to an SSL certificate file that does not exist. /go/checknginx repairs this situation. It:

It works only on servers that run Nginx. On an Apache server it does nothing; use checkapache there.


Quick start

/go/checknginx

Syntax

/go/checknginx

The command takes no options or arguments. Run it as root.


Options

None. Any arguments you pass are ignored.


Output

The command prints one line for each virtual host it removes:

Deleting example.com Configuration

It prints nothing when the test finds no matching error, or when the server does not run Nginx. The result of the Nginx test itself is not shown. It is saved in /usr/local/goadmio/tmp/checknginx.db.

Each run also adds a line to /var/log/go/checknginx.log.


Examples

# Check and repair
/go/checknginx
# Read the result of the Nginx test that the command saved
cat /usr/local/goadmio/tmp/checknginx.db
# Confirm that Nginx is healthy afterwards
nginx -t
# Install a new certificate for a domain whose configuration was removed
/go/ssl example.com

Troubleshooting

Symptom Likely cause Fix
Nothing is printed, but Nginx still fails The error does not mention a Let's Encrypt certificate path, or the domain has no /home/<domain>/www folder. Run nginx -t and fix the error shown.
Nothing is printed on an Apache server The command only works with Nginx. Use checkapache.
Nothing is printed, although the server runs Nginx The web server name saved in /usr/local/goadmio/linux/ws.db is not exactly NGINX in capital letters. Check the value in that file.
A domain is not served over HTTPS after the command Its virtual host was deleted because the certificate was missing, and the rebuilt one has no valid certificate yet. Install a certificate again with ssl or installssl.
The same domain is removed every time The certificate keeps going missing, for example because renewal fails. Check the domain's DNS and renew the certificate with ssl.
The test file cannot be written The command was run without root. Run it as root.

Details

What it does, in order

  1. Logs the run to /var/log/go/checknginx.log.
  2. Reads the web server name from /usr/local/goadmio/linux/ws.db. If it is not NGINX, the command stops here.
  3. Runs nginx -t and saves its output to /usr/local/goadmio/tmp/checknginx.db.
  4. Extracts every name that follows /live/ in that output, which is the domain folder inside the Let's Encrypt certificate path, and saves the list in /usr/local/goadmio/tmp/nginx.db.
  5. For each name in the list that is a hosted domain (/home/<domain>/www exists), prints Deleting <domain> Configuration and deletes the file /etc/nginx/vbost/<domain>.conf.
  6. If anything was deleted, rebuilds the configuration with conf.

Which errors it handles

Only errors whose text contains a Let's Encrypt path such as /etc/letsencrypt/live/example.com/... are handled, typically a certificate or key file that does not exist or cannot be loaded. Other configuration errors are saved in the test file but are not fixed.

Difference from checkapache

checknginx checkapache
Web server Nginx Apache
File deleted The whole virtual host file of the domain Only the SSL virtual host file of the domain

Known issues


See also

Command Description
checkapache Validate the Apache configuration
conf Rebuild the Apache/Nginx configuration in GoAdmio
nginx Convert a GoAdmio server from Apache to Nginx
ssl Install an SSL certificate for a domain in GoAdmio
checkssl Check if SSL certificates are installed for all domains
reload Reload PHP-FPM and the active web server