1

I've setup a store on Magento 2 that is going to go live soon. I wanted to implement Varnish, but my hosting says that it is not compatible with cPanel. They did install it, but they're facing problem when they run it. They're suggesting that I use nginx as reverse proxy server instead. I've little knowledge of servers and don't know how that can be done. I've searched the web but can't find a concrete document that explains how to use nginx as full page caching / reverse proxy server, just like how Magento 2 uses varnish. My objective is of course to speed up my site.

I'm also confused on how Magento 2 would interact with nginx as a proxy server instead of Varnish since it does not have built in support for nginx. For instance, would Magento 2 automatically purge a product page that is cached if say price of that product is updated on the backend?

Can someone kindly brief me and let me know on how to achieve my goal. Would be grateful for all the help. Thank you.

  • Varnish is a caching server; nginx is a proxy or reverse proxy. If you're unable to use Varnish, you could still use Redis for page caching. – Steve Johnson Jul 17 '16 at 22:07
  • Possible duplicate of Domain Issue and Varnish Extension – MagenX Jul 18 '16 at 11:27
  • varnish and redis are totally different – MagenX Jul 18 '16 at 11:29
1

Magento requires that cache storage allows cleaning values by tags. Nginx do not support it. So, you cannot implements full functionality in stock Nginx at all.

But if not valid data for some time is valid for you business, you can enable php implementation of FPC and add cache in nginx with invalidation by time

|improve this answer|||||
0

Simply avoid Cpanel and hosts which use it. You should be using bare bones Linux distribution, whereas Cpanel acts like rootkit to a system and prevents the use of decent performance software like Varnish.

Magento 2 is so very compatible with Varnish and these are great news for anyone. Get a host without crappy panel-ware, install Varnish, Nginx, transfer your Magento, be happy.

|improve this answer|||||
  • hm, cPanel sucks, but Varnish works anywhere, even with cPanel installed... – MagenX Jul 18 '16 at 11:25
0

In case anyone else comes across this issue I wrote up a solution here on how to use Nginx and Varnish on a CPanel server

https://github.com/engintron/engintron/issues/711

|improve this answer|||||
-1

My solution is going to be related to Magento with HTTPS enabled.

You will need to setup nginx and create a total of 3 server contexts for a single installation.

1st one will listen on port 80 and will redirect all traffic to port 443.

2nd one will listen on port 443 and will redirect all traffic to port Varnish listening port(def is 6088).

3d one will be the backend that Varnish send the MISS/HIT-FOR-MISS tagged requests. This will have all the logic that a normal Nginx server would execute.

For Varnish you will need to extract the Varnish VCL from Magento. For this login to you admin panel and find Under system the panel related to Full page cache(cannot remember the right path) and change the default system value to Varnish. Scroll down and you will find the Varnish Version you want to extract for. I recommend to use Varnish v4 which i have already tested and is working.

image below shows the Panel i am talking about : taken from http://devdocs.magento.com/guides/v2.0/config-guide/varnish/config-varnish-magento.html

Varnish VCL extract

Also check a post of mine that leads to the solution of a problem you might face.

Magento 2+nginx+varnish cannot server same page multiple times, resp 502

Last, but not least, you will need to add some more configurations for nginx to improve overall performance, but that is another story on it's own.

Cheers.

Edit: My configuration are also using php-fpm to take care of php so you will need to make changes depending on your setup for it to work properly. Don't go all out copy paste squad while using Nginx+Varnish+Magento+Something for php becouse you will have a bad day :)

|improve this answer|||||
  • your config is absolutely useles... why did you copy paste it here??? – MagenX Dec 18 '17 at 10:49
  • @MagenX It is just an example of how i managed to make this work from a dead demo. What do you mean with useless? – 1337_sanc Dec 18 '17 at 12:11
  • So could you please be more productive and explain the reason behind downvoting? I do not understand the "useless" nature of posting some configs that work. Optimal? No. I also mentioned that he should look into optimizing, changing and not go all out copy paste. – 1337_sanc Dec 21 '17 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.