{"id":200,"date":"2015-06-19T15:01:32","date_gmt":"2015-06-19T15:01:32","guid":{"rendered":"https:\/\/www.prolimehost.com\/blogs\/?p=200"},"modified":"2017-01-04T16:59:19","modified_gmt":"2017-01-04T16:59:19","slug":"understanding-varnish-web-accelerator-installation-process","status":"publish","type":"post","link":"https:\/\/www.prolimehost.com\/blogs\/understanding-varnish-web-accelerator-installation-process\/","title":{"rendered":"Understanding Varnish Web Accelerator & Installation Process"},"content":{"rendered":"
Varnish is a tool that accelerates the HTTP server and can act as a reverse proxy as well.<\/p>\n
Varnish can be installed as the front end to your web server (Apache or Nginx). Nginx uses the principle of storing the data in its cache rather than in the hard disk. We thus need to minimize the RAM memory allocated to Varnish to keep the costs down.<\/p>\n
The client or web server sends HTTP\u00a0requests to varnish. Varnish then sends the requests to the web server. The web server returns the responses to Varnish. Varnish returns the responses to the client. The Varnish software also stores the https responses in its cache so that when it receives similar requests from the client it directly sends the responses rather than contacting the server and thus the process becomes much faster. The processing load in the web server is also reduced to a great extend by incorporating Varnish in between the client and the web server.<\/p>\n
Varnish effectively reduces the web server’s CPU\u00a0load. It is well suited for websites with very high traffic. The websites will be very fast when Varnish is used.<\/p>\n
Installation of Varnish on a CentOS server<\/p>\n
Varnish is part of the EPEL repository and so we first install the EPEL repository.<\/p>\n
#rpm -iUvh https:\/\/dl.fedoraproject.org\/pub\/epel\/7\/x86_64\/e\/epel-release-7-5.noarch.rpm
\n#yum update
\n#yum install varnish<\/p>\n
We start varnish as the root user.
\n# service varnish start<\/p>\n
We can check and verify whether Varnish is running successfully through the below command:
\n# service varnish status<\/p>\n
Next we can make sure tat the Varnish server automatically runs every time the server boots:
\n# chkconfig –level 345 varnish on<\/p>\n
Next we move to the Varnish configuration file.<\/p>\n
The Varnish configuration files are \/etc\/sysconfig\/varnish and \/etc\/varnish\/varnish.vcl.
\n\/etc\/sysconfig\/varnish contains all the environment variables required for varnish to work properly.
\nThe file \/etc\/varnish\/varnish.vcl contains the values for the caching policy of varnish.<\/p>\n
Varnish stands in between the client and the web server. Hence we need to make a few changes in the configuration.<\/p>\n
We change the default listening port of Varnish to port 80. We change the default port that the web server listens to port 8080.
\nWe then need to redirect the incoming traffic to Varnish to the web server. This is done automatically by Varnish once we have done the port settings correctly for both the Varnish server and for the web server.<\/p>\n
In our web server, say Apache or Ngnix make sure that we have set the server to listen on port 8080 instead of the default port i.e., port 80.<\/p>\n
For the Apache server, go to the configuration file \/etc\/httpsd\/conf\/httpsd.conf and make sure that the \u201cListen\u201d\u00a0 parameter is set to port 8080<\/p>\n
Listen 8080<\/p>\n
For the Nginx server, goto the nginx configuration file \/etc\/nginx\/nginx.conf\u00a0 and set the listen parameter to 8080 in the server block.<\/p>\n
We can test whether Varnish works correctly by executing the Curl command from the command line in our server.<\/p>\n
# curl -I https:\/\/ localhost<\/p>\n
Varnish also contains two tools named Varnish Cache\u00a0 that displays the Varnish stats and varnishlog that displays the varnish logs.<\/p>\n
Brought to you by ProlimeHost<\/strong><\/p>\n We\u2019ve been in the web hosting industry for ten years, helping hundreds of clients succeed in what they do best and that\u2019s running their business. We specialize in\u00a0VPS<\/a>\u00a0and\u00a0dedicated servers<\/a>, with data centers in Los Angeles, Denver and Singapore. \u00a0Call\u00a0+1 877 477 9454 or email us at Sales@ProlimeHost.com. We\u2019re here to help.<\/p>\n <\/p>\n","protected":false},"excerpt":{"rendered":"Varnish is a tool that accelerates the HTTP server and can act as a reverse proxy as well.…","protected":false},"author":2,"featured_media":201,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":"","footnotes":""},"categories":[10],"tags":[],"class_list":{"0":"post-200","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials-tips","8":"cs-entry"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/comments?post=200"}],"version-history":[{"count":0,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/posts\/200\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/media\/201"}],"wp:attachment":[{"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/media?parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/categories?post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.prolimehost.com\/blogs\/wp-json\/wp\/v2\/tags?post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}