Installation and configuration of varnish in Ubuntu9.10

Source: Internet
Author: User
Environment: Ubuntu9.10; squid listening 173.26.100.214: 80; varnish listening 173.26.100.214: 811. Install * in Environment: Ubuntu 9.10; squid listening environment: 80; varnish listening 173.26.100.214: 81
1. Install
* In logging.
* Tar zxvf varnish-2.0.4.tar.gz
* Run./autogen. sh in the decompressed varnish-2.0.4 directory.
*./Configure -- prefix [specify the directory as dir] -- enable-developer-warnings -- enable-debugging-symbols
* Make
* Make install
2. Configuration
Create cache directory:
Mkdir-p/cache/varnish/V & chown-R 777/cache
Write the startup script. The following is my startup script:
#! /Bin/sh
# File: start. sh
Date-u
/Usr/local/varnish/sbin/varnishd-a 173.26.100.214: 81-s file,/cache/varnish/V, 1024 m-f/usr/local/varnish/etc/varnish/default. vcl-p thread_pool_max = 1500-p thread_pools = 5-p listen_depth = 512-p client_http11 = on
Modify the configuration under dir/etc/varnish/default. vcl. The following is a part of my Configuration:
Backend default {
. Host = "173.26.100.214 ";
. Port = "80 ";
}/* Squid for backend */
Sub vcl_recv {
If (req. request! = "GET "&&
Req. request! = "HEAD "&&
Req. request! = "PUT "&&
Req. request! = "POST "&&
Req. request! = "TRACE "&&
Req. request! = "OPTIONS "&&
Req. request! = "DELETE "){
/* Non-RFC2616 or CONNECT which is weird .*/
Return (pipe );
}
If (req. request! = "GET" & req. request! = "HEAD "){
/* We only deal with GET and HEAD by default */
Return (pass );
}
If (req. http. Authorization | req. http. Cookie ){
/* Not cacheable by default */
Return (pass );
}
Return (lookup );
}

Sub vcl_pipe {
Return (pipe );
}

Sub vcl_pass {
Return (pass );
}

Sub vcl_hash {
Set req. hash + = req. url;
If (req. http. host ){
Set req. hash + = req. http. host;
} Else {
Set req. hash + = server. ip;
}
Return (hash );
}

Sub vcl_hit {
If (! Obj. cacheable ){
Return (pass );
}
Return (deliver );
}

Sub vcl_miss {
Return (fetch );
}

Sub vcl_fetch {
If (! Obj. cacheable ){
Return (pass );
}
If (obj. http. Set-Cookie ){
Return (pass );
}
Set obj. prefetch =-30 s;
Return (deliver );
}

Sub vcl_deliver {
Return (deliver );
}

Sub vcl_discard {
/* XXX: Do not redefine vcl_discard {}, it is not yet supported */
Return (discard );
}

Sub vcl_prefetch {
/* XXX: Do not redefine vcl_prefetch {}, it is not yet supported */
Return (fetch );
}

Sub vcl_timeout {
/* XXX: Do not redefine vcl_timeout {}, it is not yet supported */
Return (discard );
}

Sub vcl_error {
Set obj. http. Content-Type = "text/html; charset = UTF-8 ";
Synthetic {"

Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>


"} Obj. status" "obj. response {"


Error "} obj. status" "obj. response {"

"} Obj. response {"


Guru Meditation:

XID: "} req. xid {"



Varnish



"};
Return (deliver );
}
According to tests, varnish's proxy access speed is more than 10 times faster than squid.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.