Nginx directive does not work properly when set via Plesk

Created:

2016-11-16 12:52:40 UTC

Modified:

2017-08-08 13:16:10 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Nginx directive does not work properly when set via Plesk

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux

Symptoms

Plesk runs with Nginx + php-fpm server. When add directive to nginx configuration for domain at Subscriptions > example.com > Websites & Domains > Web Server Settings > Additional nginx directives the directive does not work properly. The following rule was set:

    location ~ /$ {
index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
try_files $uri $uri/ /index.php?$args;
}

instead of default values:

    location ~ /$ {
index index.html index.cgi index.pl index.php index.xhtml index.htm index.shtml;
}

Cause

Rewrite rules are not adopted for nginx + php-fpm configuration.

Resolution

Described rules are written for apache webserver and should be adopted for nginx syntax. For instance, the initial rule:

...
try_files $uri $uri/ /index.php?$args;
...

is equivalent to bellow one for nginx:

...
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
...

To implement the changes place the adopted rule above in domain configuration file via Plesk GUI:

Subscriptions > example.com > Websites & Domains > Web Server Settings > Additional nginx directives

More details on rules conversion can be found at http://ext.plesk.com

Have more questions? Submit a request
Please sign in to leave a comment.