Install Varnish Cache with Nginx SSL Termination in Shopware
Aneesh . 4 minutes

How to Install Varnish Cache with Nginx SSL Termination in Shopware 6.7

Many official resources and community tutorials on installing Varnish for Shopware 6.7 focus only on standard HTTP setups. They often overlook the critical need for securing your site with SSL.

But for today’s e-commerce retailers, performance and security are equally essential for earning customer trust and ensuring a smooth shopping experience.

This in-depth guide walks you through installing and configuring Varnish for Shopware 6.7 with full SSL termination. By following these steps, you’ll combine Varnish’s powerful caching capabilities with the security of HTTPS. This will results in a lightning-fast, secure storefront.

We’ll cover how to:

  • Prepare your system
  • Compile the required Varnish version (7.6+)
  • Integrate Varnish with Shopware’s HTTP cache
  • Configure Nginx to handle SSL termination cleanly

This guide assumes your Shopware instance is already running on Nginx with SSL enabled. Our goal is to evolve that setup into Nginx + Varnish, with SSL termination handled by Nginx itself.

Important: The default Varnish package in Ubuntu repositories lacks modules required for Shopware compatibility. We’ll show you how to manually compile Varnish 7.6+ to ensure optimal functionality.

Whether you’re optimizing an existing store or setting up a new one, this hands-on tutorial will give you the confidence to deliver a secure, high-performance Shopware 6.7 site.

Let’s get started.

We’ve already implemented this Varnish + SSL setup for a few of our Shopware clients. If you’re tackling something similar and need technical support, our team is happy to help.

Varnish Installation and Configuration

Let’s walk through the process of installing and configuring Varnish 7.7 for Shopware 6.7, with full SSL support handled via Nginx.

Step 1:  Let’s Install the Build Dependencies for Compiling Varnish

Step 2: Download and Extract Varnish

Download Varnish Package

Extract and navigate to the directory

Step 3: Compile and Install Varnish

Prepare the build system.

Configure the build

Build the source

Install Varnish

Step 4: Install Varnish modules for Shopware

Download the Varnish module for Shopware

Use a branch matching your Varnish version (e.g., 7.7)

Compile and install them

Step 5: Create Varnish Configuration File

Create the Varnish Configuration file /etc/default/varnish.vcl with the following contents:

Step 6: Set Up a Systemd Service for Varnish

Create a SystemD service file for Varnish and enable it to startup during boot  /etc/systemd/system/varnish.service and reload the systemd daemon to apply.

Then reload the systemd daemon:

Step 7: Ensure Varnish Finds Installed Modules

Since we installed Varnish modules manually, Varnish won’t be able to find those modules. Let’s fix that. Create a file /etc/ld.so.conf.d/local-lib.conf with the following content:

Run the following commands to make sure libvarnishapi is loaded

Expected Output: (note the libvarnishapi)

Step 8: Start and Enable the Varnish Service

Start Varnish service and enable it to start during boot

Need speed? We’ll configure Varnish & Nginx for Shopware.

Nginx Configuration for SSL Termination and Varnish Proxy

With Varnish now installed and configured, it’s time to adjust your Nginx setup to act as the SSL terminator and proxy incoming HTTPS requests to Varnish.

Now, let’s move to nginx

Update your nginx vhost configuration accordingly:

After applying the changes, ensure the configuration is valid and reload Nginx:

Shopware Configuration for Varnish Compatibility

Now, let’s move to the configuration of Shopware. 

Create the following configuration file in your Shopware installation config/packages/shopware.yml

Also, in your .env or .env.local, make sure to enable 

Create a configuration config/packages/trusted_env.yaml with the following content to trust the proxy because we have multi-layer routing.

 (If we don’t do this, Shopware resources will be loaded over HTTP, resulting in a mixed content error and broken styles.)

Add/Update your .env.local file with the following

Now navigate to your project directory and clear cache

Restart Varnish to clear the cache one more time

To make sure the varnish cache is working properly, you can try this in a terminal. After running this curl command 2 or more times, you should eventually land a response with “HIT”

Note: In some cases, there might be plugins that cause Shopware to send a no-cache header, which can prevent Varnish from delivering a cache HIT for certain resources. Be sure to check your plugin settings and headers thoroughly during your setup and troubleshooting.

Conclusion

This guide covered installing Varnish Cache with Nginx SSL termination for Shopware 6.7. This helps to create a secure, high-performance e-commerce infrastructure. At 2hats Logic Solutions, we work with implementing and supporting these advanced caching setups for Shopware stores. This combination dramatically improves page load times while maintaining enterprise-grade security. Contact us to work with experts who can implement this for you.

Want expert help speeding up your Shopware store with Varnish and Nginx? We’re here to support.

FAQ

Can I use the standard Varnish installation for Shopware 6.7 speed improvement?

No, the standard version doesn't include the special features Shopware needs. You need to install a custom version with extra components to make your Shopware store work properly with caching.

How does Varnish work with SSL certificates on Shopware stores?

Varnish doesn't handle SSL directly. Your web server (Nginx) manages the SSL security, then sends requests to Varnish for caching, which then connects to your Shopware store. This keeps your site secure while making it faster.

Will my Shopware admin area still work with Varnish caching?

Yes, the setup automatically skips caching for admin pages, checkout, and customer accounts. Your admin panel and customer login areas will work exactly as before, while your product pages load much faster.

blog
Greetings! I'm Aneesh Sreedharan, CEO of 2Hats Logic Solutions. At 2Hats Logic Solutions, we are dedicated to providing technical expertise and resolving your concerns in the world of technology. Our blog page serves as a resource where we share insights and experiences, offering valuable perspectives on your queries.
Aneesh ceo
Aneesh Sreedharan
Founder & CEO, 2Hats Logic Solutions
Subscribe to our Newsletter
Aneesh ceo

    Stay In The Loop!

    Subscribe to our newsletter and learn about the latest digital trends.