Symptoms
- Trying to add location
/
directive in Domains > example.com > Apache & nginx Settings > Additional nginx directives fails with the following error:Invalid nginx configuration: nginx: [emerg] duplicate location "/" in /data/www/system/example.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed
Cause
Location /
is already defined in the main domain configuration file /var/www/vhosts/system/example.com/conf/nginx.conf
when the Nginx service is enabled as a reverse proxy
Resolution
Note: In the case that the additional directives that are needed to be added are for enabling Permalinks from WordPress, please use this article: After switching a WordPress website to FPM served by nginx in Plesk, it fails to load with "404 Not Found" on all pages except start page
To add location /
to additional nginx directives:
Create custom virtual hosts configuration templates
See the below documentation article for more details:
Changing Virtual Hosts Settings Using Configuration Templates
Warning: The changes in the virtual hosts configuration templates are applied to all domains on the server.
Disable Nginx proxy mode on the domain
-
In Domains > example.com > Apache & nginx directives temporary remove additional nginx directive containing
location /
; -
Disable Proxy Mode and click Apply
-
Insert the necessary directive back into Additional nginx directives and click Apply