You’re now ready to restart varnish to take your changes into account:
systemctl restart varnish
Now point your favourite browser to your domain, and if you did everything right, you’ll see your varnish-accelerated page.
Alternatively, here’s how it looks for me when I ‘curl’ it from my desktop/laptop:
curl -LIs https://evervee.me
returns:
HTTP/1.1 200 OK Server: nginx Date: Mon, 26 Jun 2017 17:49:38 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Vary: Accept-Encoding Age: 7 Via: carrier pigeon and smoke signals X-Powered-By: hopes and dreams X-Cache: HIT Accept-Ranges: bytes Strict-Transport-Security: max-age=31536000; includeSubDomains
Two subsequent curl calls will show how Varnish first didn’t have the resource in memory, but for the second ‘visit’, it definitely serves it from memory, as opposed to letting nginx (which is already fast) process it from disk, which by the sheer nature of physics, is slower, especially at scale.
Let me know if any of the steps don’t work for you and I’ll try to help you 🙂
//V
Later edit:
Damn this thing is fast! Sub-second response times are fantastic for this exact blog post:
time curl -LIs https://evervee.me/tech-work/wordpress-ssl-php-fpm-nginx-varnish-nginx-sandwich/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 26 Jun 2017 18:12:01 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Age: 20
Via: carrier pigeon and smoke signals
X-Powered-By: hopes and dreams
X-Cache: HIT
Accept-Ranges: bytes
Strict-Transport-Security: max-age=31536000; includeSubDomains
real 0m0.539s
user 0m0.025s
sys 0m0.009s
That’s including visiting it from North America, and the VPS I’m hosting this on is in Europe (so add the usual 100-200+ ms latency for the data to be crossing that big ass ocean as well)
Without Varnish, the load times are usually in the 3-5 second range, for light pages (not too many big pictures and whatnot)…
So, yay ^^
HTTP/1.1 403 Forbidden
Server: nginx/1.10.3 (Ubuntu)
Date: Sat, 29 Sep 2018 17:23:22 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
i get this response
would you mind posting both your NGINX configuration as well as your Varnish configuration? Also, please be specific as to your OS flavor and version.
1. Your tutorial works for me. But after I logged in with admin account, access any url with “/wp-admin/*”, results a 302 (see below). Any ideas?
162.158.90.189 – – [13/Dec/2018:15:48:34 +0000] “GET /home/wp-admin/post-new.php HTTP/1.1” 302 0 “https://tapchiamnhac.net/home/” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36”
2. In some tutorial, they added the following configs. Do we need them?
define( ‘WP_HOME’, ‘https://your-site’ );
define( ‘WP_SITEURL’, ‘https://your-site’ );
define(‘FORCE_SSL_ADMIN’, true);
define(‘FORCE_SSL_LOGIN’, true);
Keep this going please, great job!
thank you! will do, keep eyes peeled for more tech articles 🙂