In this video, we’ll explain how to avoid mixed content and a redirect loop when running Varnish on WordPress.
Both issues are related to a lack of TLS awareness. When you install Varnish in front of your WordPress application, all communication between Varnish and WordPress is done over plain and unencrypted HTTP. WordPress is unaware of this, despite there being a TLS session that was terminated by a TLS proxy in front of Varnish.
This results in mixed content because the page is served over HTTPS, but all other resources in the HTML output are loaded over plain HTTP because of this limitation in WordPress. This video will demonstrate how to create TLS awareness in WordPress through the X-Forwarded-Proto header.
The second problem arises when WordPress enforces HTTP to HTTPS redirection. Varnish will cache that redirection, but will not make a distinction between HTTP and HTTPS when this content is requested. This means HTTPS requests will still get redirected to the HTTPS version of that resource, resulting in a redirect loop.
This video shows how to use cache variations to make Varnish protocol aware when storing objects in the cache.
00:00 Intro
00:36 WordPress, Varnish & TLS
01:32 Mixed content
01:58 Redirect loop (ERR_TOO_MANY_REDIRECTS)
02:52 X-Forwarded-Proto
03:33 Setting X-Forwarded-Proto in VCL
04:40 Enabling HTTPS in WordPress through the X-Forwarded-Proto header
05:17 Enabling HTTPS in Apache through the X-Forwarded-Proto header
05:42 Enabling HTTPS in Nginx through the X-Forwarded-Proto header
06:16 Mixed content problem solved
06:37 Creating cache variations to fix the ERR_TOO_MANY_REDIRECTS problem
07:32 Creating cache variations in Apache
07:51 Creating cache variations in Nginx
08:07 Creating cache variations in
08:37 Outro
#Avoid #Mixed #Content #Redirect #Loops #WordPress