/plesk-nginx-fascgi-cache-template

Custom Nginx WordPress VirtualHost template with Nginx fastcgi_cache for Plesk Onyx

Primary LanguagePHPMIT LicenseMIT

Nginx Fastcgi_cache custom template for Plesk Onyx

Features

  • Override default Nginx virtualhost template to work with WordPress in mode "Nginx Only"
  • set fastcgi_cache bypass rules globally on the server using the directive map instead of several "if".
  • add support for Nginx fastcgi_cache purge with Nginx-helper
  • Bypass cache on cookies or request_uri
  • add webp image rewrite support
  • Deny access to hidden files and directory (.git, .htaccess, etc ..)

Requirements

  • Nginx compiled with Nginx_cache_purge module : You can use nginx-ee to compile Nginx

Custom template compatible with stock Nginx package shipped by Plesk, available here : nginx-stock

Limitations

  • Custom rules to bypass cache set in Plesk are not applied
  • fastcgi_cache template work only for wordpress

How to use this template

  1. Clone the repository
git clone https://github.com/VirtuBox/plesk-nginx-fascgi-cache-template.git /usr/local/psa/admin/conf/templates/custom
  1. Copy Nginx configuration in Nginx conf.d directory
cp -f /usr/local/psa/admin/conf/templates/custom/nginx-conf/* /etc/nginx/conf.d/
  1. Reload nginx
nginx -t && service nginx reload
  1. Apply new nginx virtualhost template
# let plesk detect custom template
plesk repair web -n
# rebuild vhost with custom template
plesk repair web -y -domains-only
  1. Disable Proxy mode in Plesk > Yourdomain.tld > Apache & nginx Settings

  2. Enable Nginx cache in Plesk > Yourdomain.tld > Apache & nginx Settings

  3. Login into WordPress & install Nginx-helper plugin

  4. In Nginx-helper Settings, Enable Purge

How to update this template

Just run :

git -C /usr/local/psa/admin/conf/templates/custom pull origin master

And relaunch plesk repair web to apply changes :

# let plesk detect custom template
plesk repair web -n
# rebuild vhost with custom template
plesk repair web -y -domains-only