Plesk

Additional nginx directives are not applied when nginx proxy mode is disabled in Plesk

Symptoms

  1. Additional nginx directives are not applied (for example, leverage browser cache settings):

    location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    expires max; log_not_found off;
    }

  2. nginx proxy mode at Domains > example.com > Apache & nginx settings is disabled (all content is served by nginx).

  3. "Serve static files directly by nginx" option is enabled Domains > example.com > Apache & nginx settings

Cause

The option "Serve static files directly by nginx" interferes with additional nginx directives.

Resolution

Disable "Serve static files directly by nginx" for a single domain

  1. Login to Plesk
  2. Navigate to Domains > example.com > Apache & nginx settings
  3. Disable the option Serve static files directly by nginx and press OK.

Disable "Serve static files directly by nginx" for all domains

  1. Connect to the server via SSH

  2. Execute the following command to disable the option for all domains where it is enabled:

    # for i in $(plesk bin domain -l); do j=$(plesk bin domain --show-web-server-settings $i | grep -A 1 nginx-serve-static | awk 'FNR==2 {print}'); printf "$i: $jn"; [ "$j" == "true" ] && plesk bin domain --update-web-server-settings $i -nginx-serve-static false; done