Skip to content
  • Solutions
    By Role
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    • For Developers
    • For Content Managers
    • For Agencies
    • For IT Admins
    • For Web Hosters
    By Infrastructure
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Overview
    • AWS
    • Microsoft Azure
    • Alibaba Cloud
    • Google Cloud Platform
    • Vultr
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
    • Digital Ocean
    • Linode
    • Upcloud
    • Oracle
    • OVH
  • Product
    • Plesk Features
    • Plesk Editions
    • What’s new
    • Pricing
    • Roadmap
    • Lifecycle Policy
    • Extensions Catalogue
  • Pricing
  • Extensions
    Featured Extensions
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder for Plesk
    • SEO Toolkit
    • Joomla! Toolkit
    • Premium Email
    • Email Security
    Bundles and packs:
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack
    • Business and Collaboration Edition
    • WP pack
    • Hosting pack
    • Power pack
    • Language pack

    See all Extensions

  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
  • Pricing
  • Solutions
    • By Role
      • For Developers
      • For Content Managers
      • For Agencies
      • For IT Admins
      • For Web Hosters
    • By Infrastructure
      • Overview
      • Plesk on Amazon Web Services (AWS & Lightsail)
      • Microsoft Azure
      • Alibaba Cloud
      • Google Cloud Platform
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
      • Oracle
      • OVH
  • Products
  • Pricing
  • Extensions
    • Featured Extensions
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Joomla! Toolkit
      • Premium Email
      • Email Security
    • Bundles and packs:
      • Business and Collaboration Edition
      • WP pack
      • Hosting pack
      • Power pack
      • Language pack
      • See all Extensions
  • For Partners
    • Plesk Contributor Program
    • Plesk Partner Program
    • Affiliate Program
    • Plesk University
  • Help Center
    • Documentation
    • Professional Services
    • Support
    • Contact Us
    • Wiki
    • Forum
  • Plesk 360 login
  • Free Trial
Plesk 360 login
Free Trial

Knowledge Base

How to configure varnish cache for a domain in Plesk?

 
301 redirectapachecachecrondocker

Question

How to configure varnish cache for a domain in Plesk?

Answer

This can be achieved in two ways - with a local Varnish server, or with Docker container.

Docker
Local Varnish server

1. Initial docker preparation and configuring varnish for a static page

  1. Log into Plesk

  2. Navigate to Docker in Plesk, find and the official varnish image in the catalog, click mceclip1.pngand select the stable(6.6.2) version to run a varnish containre:
    mceclip0.png

  3. Setup Manual Mapping for the docker container. At Docker > varnish > Settings uncheck the "Automatic Port Mapping" function and apply the following manual mappings:

    80 -> 32780
    8443 -> 32781 (we're not going to use this one)

  4. Disable the "Permanent SEO-safe 301 redirect from HTTP to HTTPS" option on the domain at Domains > example.com > Hosting Settings

  5. Create a Docker Proxy Rule on the domain at Domains > example.com > Docker Proxy Rules:
    URL: example.com/
    Container: varnish
    Port: 80 -> 32780
    proxyrules.png

  6. Permit connections to the apache2 port 7080 from the docker subnet via iptables:
    6.1 Connect to the server via SSH
    6.2 Apply the rule using the next command:

    # iptables -I INPUT -p tcp --dport 7080 -s 172.17.0.0/24 -j ACCEPT

    Note: The rule added via command line would be reset on the system reboot, or after applying a custom firewall script/configuration. In order to make it persistent, rather include it in your iptables configuration, or consider scheduling a server-wide cron task.

  7. In case there is a Plesk Firewall extension in use, navigate to Tools & Settings > Security(Firewall) > Add Custom Rule:
    pleskfirewall.png
    7.1 Once the rule is saved, click the "Apply Changes" and "Activate" buttons.

    Note: make sure the docker container was restarted once the Firewall Rules were applied via extension.
    7.2 (Optional) if Fail2ban is used, add the docker network to a trusted list.
    Navigate to Tools & Settings > IP Address Banning (Fail2Ban) > Trusted IP Addresses and click Add trusted IP: 172.17.0.0/24

  8. Using the next two commands, adjust the Varnish configuration file to use the IP and port of the apache2:

    Warning: The domain's IP address should be specified instead of 203.0.113.2, otherwise you will break the docker container. Also, if the container's name was changed from "varnish" to a custom one, don't forget to adjust it within the commands below:

    # docker ps | grep varnish | awk {'print $1'} | xargs -i docker exec -t {} sed -i '/.port/c .port = "7080";' /etc/varnish/default.vcl

    # docker ps | grep varnish | awk {'print $1'} | xargs -i docker exec -t {} sed -i '/.host/c .host = "203.0.113.2";' /etc/varnish/default.vcl

  9. Restart the varnish container:

    # docker ps | grep varnish | awk {'print $1'} | xargs -i docker restart {}

  10. Starting with Plesk 18.0.56 apache2 now listening on localhost. To make docker container able to fetch data from 0.0.0.0:7080, it is needed to change the apache2 bindings via the next command:

    Warning: The operation will take time depending on the server performance and number of domains. Downtime for domains while the operation is performed is expected.

    # plesk bin apache --listen-on-localhost false

  11. Open the website via browser and check the headers of the page…

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Cron Jobs: All You Need To Know

Read More »

Your Complete .htaccess Guide: Including .htaccess Basics and More

Read More »

NGINX vs Apache – Which Is the Best Web Server in 2024?

Read More »
Knowledge Base

How to customize Plesk URL

Read More »

Why there is no redirect from http to https to access Plesk login page?

Read More »

Operation in Plesk fail with “Error: no secure shell available”: chroot: failed to run command ‘/bin/bash’: Permission denied

Read More »

Unable to issue a Let’s Encrypt certificate: The token file is either unreadable or does not have the read permission

Read More »

Hosting Wiki

  • Docker
  • Content Security Policy ( CSP )
  • Server Redundancy
  • CacheFly
  • Bare Metal Server
  • Oracle VM Server
  • Server Virtualization Software
  • Windows Server
  • JavaScript
  • HTTP/3
  • HTTP/2
  • Domain
  • Hosting Control Panel
  • Plesk
  • Lighttpd
  • Apache Tomcat
  • Apache
  • Web Server
  • DNS Server
  • IPv6
  • IPv4
  • SIP
  • UDP/IP
  • URL
  • Firewall
  • Cron Jobs
  • Network Bandwidth
  • Colocation Hosting
  • Reseller Hosting
  • Cloud Hosting
  • VPS Hosting
  • Dedicated Hosting
  • Shared Hosting
  • Free Hosting
  • Managed Hosting
  • TCP/IP
  • HTTP
X-twitter Linkedin Youtube Reddit Github
  • Product
  • Login
  • Pricing
  • Editions
  • For Partners
  • Partner Program
  • Contributor Program
  • Affiliate Program
  • Plesk University
  • Company
  • Blog
  • Careers
  • Events
  • About Plesk
  • Our Brand
  • Resources
  • User and Admin guides
  • Help Center
  • Migrate to Plesk
  • Contact Us
  • Hosting Wiki
  • Forum
  • Legal
  • Legal
  • Privacy Policy
  • Imprint

© 2025 WebPros International GmbH

Part of the WebPros®  Family