@Kaspar Thank you for your provided article. Unfortunately, that only resolves the case when you have access to root. Otherwise, it is not possible to use plesk cli, as for managed servers.
The approach through XML API would be crucial to automate nginx configuration for specific domains. It seems like this is not supported.
@tertek,
It should never be supported, otherwise the attack surface would increase considerably by allowing (too much) access - code injection would be possible.
Nevertheless, I do understand your demand for "automation" of Nginx configuration.
At this moment, there are two methods to "automate" Nginx configuration.
The first method is to use Plesk custom templates and that works like charm, with one issue : the customization will always result in error notifications (that can be ignored in 98 out of 100 cases).
The second method is to create a script (bash or something else) that is run by a cronjob on a scheduled time : it allows you to "inject" specific Nginx config into the config of specific domains, but it does require some root access.
I am pretty sure that the "root access challenge" can be worked around with plain old FTP, but I would not recommend it at all.
One should always recall that Nginx configuration is not designed to be dynamic.
It essentially is static config that allows Nginx to perform and exhibit dynamic behavior.
Stated differently, your goals and objectives might not fit the optimal usage of Nginx config and/or your use-cases might require some other solution.
For instance, "automating" Nginx directives in a couple of domains is not a good idea.
The custom Nginx config should be of that nature and excellence that it would not have to change, never.
So, a simple addition of a config LINES via Plesk GUI should suffice for a very long period.
However, there are some use-cases where the Nginx config is created in a dynamic fashion.
For instance, the creation of dynamic blocklists (with a combination of Fail2Ban and Nginx) creates a static (not dynamic) Nginx file that changes each time an IP has been added or removed - this custom Nginx config file simply requires a task-based reload of Nginx config (and that is easily done in Plesk GUI).
Moreover, there are some use-cases that require server-wide customization.
In this case, the server-wide customization can be achieved with Plesk custom templates OR plain old static Nginx config files, depending on the use-case that is applying and/or depending on the objectives.
In general, Nginx is rather versatile and "Nginx automation" should not be necessary.
In addition, Plesk custom templates are only necessary in those cases where Plesk default templates fail miserably (and that happens).
So, I am not entirely sure why you would go the length of Plesk extension development (which will not result in you achieving your goals) and I am certainly not sure why you want to automate Nginx.
Could you elaborate on that?
Kind regards.....