nginx emergency error unknown directive NGINX_REDIRECTS


DirectAdmin 1.61.4 to 1.61.5 update is available.
Nginx 1.19.2 to 1.19.3 update is available.

Once updated, brings up:

nginx: [emerg] unknown directive "|NGINX_REDIRECTS|" in /usr/local/directadmin/data/users/admin/nginx.conf:32
nginx: configuration file /etc/nginx/nginx.conf test failed

There may be a bug in the new release of the control, or the template shipped with the version is out of date.

Here’s a quick patch to fix it.

Custom Template for NGINX

Do you have custom templates? Check if you have files:

  • /usr/local/DirectAdmin/data/templates/custom/nginx_server.conf
  • /usr/local/DirectAdmin/data/templates/custom/nginx_server_secure.conf

If the files exist you will need to modify them.

If you don’t have them you don’t need to create them.

Default template for NGINX

If you don’t have custom templates, you will be dealing with the default template, which can be found below

  • /usr/local/DirectAdmin/data/templates/nginx_server.conf
  • /usr/local/DirectAdmin/data/templates/nginx_server_secure.conf

So now open either the custom or default template and add the following line:


in files and save them.

and then run the following command:

/usr/local/directadmin/custombuild/build rewrite_confs

This should fix the problem, you can control it in the following way:

nginx -t

You should see something like this:

[[email protected] custom]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[[email protected] custom]#

That’s it.

Leave a Comment