By Subha Pal
I already install NGINX, PHP-FPM, MariaDB and Wordpress in Ubuntu 16.04. Also, I have Let’s Encrypt SSL.
Now I want to install Varnish and configure it in the backend of NGINX since I used SSL all request from 443.
My current configuration is
User ==> Cloudflare ==> NGINX
how to configure varnish in following way
User ==> Cloudflare ==> NGINX ==>Varnish
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hi,
Since Varnish does not support SSL termination, you will need to configure nginx to do so, forward requests to Varnish, which would then forward them back to nginx over HTTP. Follow this tutorial with a few adjustments:
Use the following instructions to install Varnish: https://packagecloud.io/varnishcache/varnish41/install#manual-deb replacing trusty
with xenial
(16.04)
Configure the backend like so:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
DAEMON_OPTS="-a :6081 \
with ``DAEMON_OPTS="-a 127.0.0.1:6081 `.Once you’ve done that, you will have Varnish configured to listen locally on port 6081 and proxy requests to 127.0.0.1:8080. Now, you’ll need to (1) move your existing nginx configuration to 127.0.0.1:8080, and (2) configure a new virtual host that handles SSL termination.
(2) is also part of the tutorial that I linked. Make sure you set proxy_pass
to http://127.0.0.1:6081;
. Finally, go into your existing virtual host, remove the SSL bits, and configure it to listen on 127.0.0.1:8080
like so:
server {
listen 127.0.0.1:80;
server_name your_domain_name;
...
}
Restart nginx and you should be able to browse to https://yourdomain
with everything working properly.
Thank you, I already figure it out few days ago !! Anyway thanks.
Is there any minimum requirement for running varnish?
I have deoplet of $5 i.e. 1 vcpu, 1GB RAM and 25 GB storage.
I run already 3 wordpress site here.
I don’t want any caching plugin to use. Is varnish will be good?
What is your opinion about server side caching vs cache plugin.
Please explain
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.