Symptoms
Unable to change nginx cache or additional nginx directives in Domains > example.com > Apache & nginx Settings that leads to failed Apache configuration:
PLESK_ERROR: ERROR: Invalid nginx configuration: nginx: [emerg] invalid condition “$request_uri” in /etc/nginx/plesk.conf.d/vhosts/example.com.conf:47 nginx: configuration file /etc/nginx/nginx.conf test failed
Disable caching for locations parameter in Nginx cache in Domains > example.com > Apache & nginx Settings was set incorrectly initially, but Plesk allowed to set it.
Cause
Product issue:
-
#PPPM-12101 “Plesk now validates custom nginx configuration before applying it. It is no longer possible to misconfigure nginx in a way that is impossible to undo via the Plesk interface.”
Fixed in:- Plesk Obsidian 27 October 2020 (Linux)
Resolution
Workaround
If update is not possible for some reason you may try the following
workaround
As a workaround, remove Disable caching for locations that is specified as nginxCacheBypassLocations from the database:
-
Connect to the server via SSH
-
Backup Plesk database:
# plesk db dump psa > psa_dump.sql
-
Find the
webServerSettingsId
for the affected domain:# plesk db -sNe “SELECT val FROM dom_param WHERE dom_id in (SELECT id FROM domains WHERE name=’example.com‘) AND param=’webServerSettingsId'”
74Replace example.com with the domain shown in the error message.
-
Remove the incorrect configuration from the database:
# plesk db “DELETE FROM WebServerSettingsParameters WHERE name=’nginxCacheBypassLocations’ AND webServerSettingsId=74“
Replace the webServerSettingsId with the ID found in step 3
-
Reconfigure all domains:
# plesk repair web -y