I know we can test nginx conf files with command line such as:
sudo /usr/sbin/nginx -c /etc/nginx/nginx.conf -t
It there any similar way to test vhost files ? I tried
/usr/sbin/nginx -c /etc/nginx/sites-available/somesite.vhost -t
but it returns weird errors.
A vhost file is usually not a complete configuration file and the test will therefore fail and return "weird errors".
However, if you have included the vhost files in your main configuration (with an
include
statement), the first test your wrote will also test all included files.If you want to test the sub files separately, your best bet would be to write a minimal valid config file and include your test file in this.