Plesk

How to add additional nginx directives globally on a Plesk server

Question

How to add additional nginx directives globally, so that these directives will not be overwritten after updates?

Answer

  1. Connect to a Plesk server via SSH.

  2. Create the directives.conf file inside the /etc/nginx/conf.d/ directory:

    # touch /etc/nginx/conf.d/directives.conf

  3. Now, open the created /etc/nginx/conf.d/directives.conf file in a text editor. In this example, we use the vi editor:

    # vi /etc/nginx/conf.d/directives.conf

  4. Add required directives. For example:

    # cat /etc/nginx/conf.d/directives.conf
    proxy_send_timeout 1200s;
    proxy_read_timeout 1200s;
    fastcgi_send_timeout 1200s;
    fastcgi_read_timeout 1200s;
    proxy_buffers 8 16k;
    proxy_buffer_size 32k;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;

  5. Save the changes and close the file.

  6. Make sure that the new directives do not break nginx configuration:

    # nginx -t
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

  7. Reload nginx configuration to apply the changes:

    # service nginx reload

Exit mobile version