- Plesk Onyx for Linux
How to enable Serve static files directly by nginx by default in Plesk > Domains > example.com > Apache & Nginx Settings?
As of now, this functionality is not implemented in Plesk. Vote for this feature at plesk.uservoice.com.
The top-ranked suggestions are likely to be included in the next versions of Plesk.
As a workaround, this can be enabled by using Event Handler in Plesk > Tools & Settings > Event Manager. For that:
Create the Event Handler:
Go Tools Settings > Event Manager > Add Event Handler.
Set fields as follows:
CONFIG_TEXT: Default domain (the first domain added to a subscription) created
CONFIG_TEXT: 0 (lowest)
CONFIG_TEXT: bash /usr/local/psa/bin/trigger.sh
trigger.shscript in /usr/local/psa/bin:
Connect to the server via SSH
Create trigger.sh as follows:
# touch /usr/local/psa/bin/trigger.sh
Use any text editor to add the following lines to the file:
date >> /tmp/log 2>&1
echo $NEW_DOMAIN_NAME >> /tmp/log 2>&1
plesk bin subscription --update-web-server-settings $NEW_DOMAIN_NAME -nginx-serve-static true -nginx-static-extensions "ac3 avi bmp bz2 css cue dat doc docx dts eot exe flv gif gz htm html ico img iso jpeg jpg js mkv mp3 mp4 mpeg mpg ogg pdf png ppt pptx qt rar rm svg swf tar tgz ttf txt wav woff woff2 xls xlsx zip" >> /tmp/log 2>&1
-nginx-serve-staticcan take the values of true or false and
-nginx-static-extensionsshould be used to specify all the extensions we want to be served by nginx.
Create a new domain. It will have Serve static files by nginx enabled by default.
Note: "Default domain created" handles is applied for newly created subscriptions only. Use "Domain created" handler and
plesk bin domain --update command in case it is required to do that for additional domains on the subscription.