It is surely not in VCL. However, do note that it's much better to start building from the provided default.vcl
, adding bits by bits, to understand how it works.
As for why it doesn't work and ways to fix it.
Different ports (duh).
Option #1. Tell your PHP what the real port is.
Perhaps, the most easy fix would be to edit wp-config.php
and tell the Wordpress where the request really came from. Add at the top of the file right after <?php
:
$_SERVER['SERVER_PORT'] = 80;
Option #2. Just use the same ports.
You can actually use same port number(!) in both Varnish and Apache. Simply bind Varnish and Apache onto different interfaces, but same port numbers. To a Linux machine those are different ports, and there is no issue using same port number.
So Apache will have:
Listen 127.0.0.1:80
Varnish will have in the VCL:
backend default {
.host = "127.0.0.1";
.port = "80";
}
Option #3. Don't use Apache. Nginx to the rescue.
A not so easy fix perhaps would be switching to Nginx which can easily circumvent the "port in redirection" problem via simply one line of configuration:
port_in_redirect off;
Wordpress base URLs.
If the Wordpress site URL (in wp-admin) is set to include port number, then naturally that's where it will redirect you. No port number should be present in Wordpress site URL.
Bonus Tip: Fix Wordpress Jetpack in Varnish.