Symptoms
-
After enabling nginx caching in Plesk at Domains > example.com > Apache & nginx settings with incorrect syntax in the Cache requests with cookies, Disable caching for locations or Cache key fields, Apache configuration gets broken.
-
The following error message may appear on the Home page in Plesk:
PLESK_ERROR: Apache config (15366822070.55014000) generation failed: Template_Exception: nginx: [emerg] pcre_compile() failed: missing ) in “(.)(?:^|;)slocation ~* .(jpg=[^;]+(?:$|;)(.*)” in /etc/nginx/plesk.conf.d/vhosts/example.com.conf:35
OR
PLESK_ERROR: New configuration files for the Apache web server were not created due to the errors in configuration templates: nginx: [emerg] pcre_compile() failed: nothing to repeat in “(.*)(?:^|;)s**=[^;]+(?:$|;)(.*)” at “*=[^;]+(?:$|;)(.*)” in /etc/nginx/plesk.conf.d/vhosts/example.com.conf
OR
PLESK_ERROR: Error Message: Invalid nginx configuration: nginx: [emerg] unknown “incorrect_value” variable nginx: configuration file /etc/nginx/nginx.conf test failedUnable to use the current nginx configuration file and to rollback to the previous version of the file because they both contain invalid configuration.
Cause
Product issue:
-
#PPPM-8395 “Expanded the list of characters that are now correctly escaped in the “Cache requests with cookies” field in nginx.”
Fixed in:- Plesk Onyx 17.8 20 August 2019 (Linux)
- Plesk Obsidian 02 July 2018 (fixed as PPP-36262, Linux)
Resolution
Workaround
If update is not possible for some reason you may try the following
temporary solution
-
In Plesk, go to Domains > example.com > Apache&nginx settings.
-
Remove incorrect configuration from the Cache requests with cookies, Disable caching for locations or Cache key fields.
-
Click OK to apply the changes.
If the changes cannot be applied, follow these steps:
-
Connect to the Plesk server via SSH.
-
Create a backup of the Plesk database:
# plesk db dump psa > psa_backup.$(date +%F_%R).sql
-
# plesk db
-
Find web server settings for example.com domain:
MYSQL_LIN: mysql> select * from WebServerSettingsParameters where webServerSettingsId in (select val from dom_param where param=’webServerSettingsId’ and dom_id=(select id from domains where name=’example.com‘));
+———————+——————————-+—————————————–+
| webServerSettingsId | name | value |
+———————+——————————-+—————————————–+
..
| 22 | nginxCacheKey | incorrect_value |
..
| 22 | nginxCacheCookies | incorrect_value | |
| 22 | nginxCacheBypassLocations| incorrect_value ||
..
+———————+——————————-+—————————————–+ -
Delete the record using
webServerSettingsId
from the previous step:MYSQL_LIN: mysql> update WebServerSettingsParameters set value=” where webServerSettingsId=22 and name=’nginxCacheCookies‘;
mysql> update WebServerSettingsParameters set value=’$scheme$request_method$host$request_uri’ where webServerSettingsId=22 and name=’nginxCacheKey‘;
mysql> update WebServerSettingsParameters set value=’$scheme$request_method$host$request_uri’ where webServerSettingsId=22 and name=‘nginxCacheBypassLocations’;
Additional information
To learn more about configuration of nginx caching, visit Enabling nginx caching – Cache requests with cookies
To learn more about configuration of explicit expires header for static files, see Configuring the “Expires” Header.