Discover Centmin Mod today
Register Now

Make Nginx robust, always to load conf vhost even if has error

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Sysnet, May 2, 2022.

  1. Sysnet

    Sysnet New Member

    7
    0
    1
    Nov 17, 2020
    Ratings:
    +0
    Local Time:
    12:13 PM
    There are multiple site config in my nginx, and when I restart the machine, if one of the sites' (vhost) has any error, nginx won't start at all, and those healthy site won't start as a result.

    Maybe I can code a program who detect this case and ignore this vhost and temporary set a template vhost (under maintenance), what do you think about this idea?


    do you know some webserver or script/panel who has this feature ?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,362
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    3:13 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You can run nginx config debug check command to see if vhost or settings are incorrect
    Code (Text):
    nginx -t
     
  3. deltahf

    deltahf Premium Member Premium Member

    586
    264
    63
    Jun 8, 2014
    Ratings:
    +487
    Local Time:
    12:13 PM
    You can also run "configtest" before restarting Nginx. It will test the config and report any errors before attempting restart:

    Code (Text):
    $ service nginx configtest
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,362
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    3:13 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Yup same as nginx -t :D