Re: Frontend caching to multiple sites

2008-11-05 Thread Alecs Henry
Hi Espen,

Thanks for the answer!

Is there a way to accomplish this using different VCLs?
I ask it because I'm trying to figure out a way to make it automatic. As in
if I have a new customer, I'd just fill out a form (with the customer
details like domain name, backend server, other configuration) and a little
system working under the hood would generate the VCL file, send it to the
varnish server and load it.

If I use one VCL file for everybody, how do I reload this VCL when I need to
change it? Is it necessary to reload varnish? Would it present downtime?

Thanks!!

Alecs



On Wed, Nov 5, 2008 at 5:58 AM, Espen Braastad [EMAIL PROTECTED] wrote:

 Alecs Henry wrote:

 I want to set up varnish as a reverse proxy/cache to multiple customer
 sites.
 As in, I have 10 different customers, each with its own web site (domains)
 with their own necessities, compression, cookie, authentication, etc; each
 customer is a different setup from the other, so I thought OK! Let's use
 a
 different VCL for each customer and all will be fine.

 Bear with me here, I've just started playing with varnish, but it seems
 that
 I can't create a different VCL file for each customer and load it in
 varnish
 (vcl.use ...) as varnish will stop responding for the previous site and
 start responding only to the new one (active configuration). Meaning, the
 content that is served is only the content from the new site, even if
 using
 the correct domain.

 How can I go about setting this up?
 I'm using Varnish 2.0.1, just downloaded and compiled it today.


 Hi,

 You can try something like this in one VCL:

 sub vcl_recv {
  if (req.http.host ~ ^(www\.)site1\.com$){
   # foo
  }

  if (req.http.host ~ ^(www\.)site2\.com$){
   # bar
  }

  if (req.http.host ~ ^(www\.)site3\.com$){
   # baz
  }

  # Unknown host
  error 403;
 }

 --
 mvh
 Espen Braastad,
 +47 21 54 41 37
 [EMAIL PROTECTED]
 Linpro AS - Ledende på Linux



___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


TCP_HIT header

2008-11-05 Thread Alecs Henry
Hi guys,

Is there a variable that I can print on the response header that will give
me the cache lookup result such as TCP_HIT or TCP_MISS?

Thanks!!

Alecs
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: TCP_HIT header

2008-11-05 Thread Alecs Henry
Hi Per,
Thanks for the reply!

The issue here is not how to add the header, that is OK, I can do it just
fine (even added the Foo: bar header just for the fun of it!). The problem
is WHAT variable I can use that contains that information (MISS or HIT).
Is there more documentation on the variables available than what is in
vcl(7)?
Or anywhere else for that matter.

Thanks,

Alecs

On Wed, Nov 5, 2008 at 3:10 PM, Per Buer [EMAIL PROTECTED] wrote:

 Alecs Henry skrev:
  Hi guys,
 
  Is there a variable that I can print on the response header that will
  give me the cache lookup result such as TCP_HIT or TCP_MISS?

 I guess you can add the relevant header in vcl_hit and vcl_miss

 See the FAQ:
 http://varnish.projects.linpro.no/wiki/FAQ#HowdoIaddaHTTPheader

 Just add a
 sub vcl_hit {
  # add code from faq here
 }



 --
 http://linpro.no/ | http://redpill.se/


___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: TCP_HIT header

2008-11-05 Thread Per Buer
Hi.

As I said. Add two different headers. One you add in vcl_hit and one
(preferably a different one) in vcl_miss. You need no variables. The
code in vcl_hit will be run for a hit and vcl_miss will be run for a miss.

Check out the getting started guide, the FAQ and the VCL-page on Wiki if
you seek documentation. Thats all there is, at the moment.

Per.




Alecs Henry skrev:
 Hi Per,
 Thanks for the reply!
 
 The issue here is not how to add the header, that is OK, I can do it
 just fine (even added the Foo: bar header just for the fun of it!). The
 problem is WHAT variable I can use that contains that information (MISS
 or HIT).
 Is there more documentation on the variables available than what is in
 vcl(7)?
 Or anywhere else for that matter.
 
 Thanks,
 
 Alecs
 
 On Wed, Nov 5, 2008 at 3:10 PM, Per Buer [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Alecs Henry skrev:
  Hi guys,
 
  Is there a variable that I can print on the response header that will
  give me the cache lookup result such as TCP_HIT or TCP_MISS?
 
 I guess you can add the relevant header in vcl_hit and vcl_miss
 
 See the FAQ:
 http://varnish.projects.linpro.no/wiki/FAQ#HowdoIaddaHTTPheader
 
 Just add a
 sub vcl_hit {
  # add code from faq here
 }
 
 
 
 --
 http://linpro.no/ | http://redpill.se/
 
 


-- 
Per Buer - Leder Infrastruktur og Drift - Redpill Linpro
Telefon: 21 54 41 21 - Mobil: 958 39 117
http://linpro.no/ | http://redpill.se/



signature.asc
Description: OpenPGP digital signature
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: TCP_HIT header

2008-11-05 Thread Alecs Henry
Hi Per,

Here's what I got:
-
vcl.load test /usr/local/etc/varnish/configs/test.vcl
106 267
*Variable 'obj.http.X-Cache' not accessible in method 'vcl_miss'.*
At: (/usr/local/etc/varnish/configs/test.vcl Line 62 Pos 13)
set obj.http.X-Cache = TCP_MISS from  server.ip;
--
VCL compilation failed
-

It works just fine for vcl_hit though.
Any ideas?

Alecs

On Wed, Nov 5, 2008 at 3:59 PM, Per Buer [EMAIL PROTECTED] wrote:

 Hi.

 As I said. Add two different headers. One you add in vcl_hit and one
 (preferably a different one) in vcl_miss. You need no variables. The
 code in vcl_hit will be run for a hit and vcl_miss will be run for a miss.

 Check out the getting started guide, the FAQ and the VCL-page on Wiki if
 you seek documentation. Thats all there is, at the moment.

 Per.




 Alecs Henry skrev:
  Hi Per,
  Thanks for the reply!
 
  The issue here is not how to add the header, that is OK, I can do it
  just fine (even added the Foo: bar header just for the fun of it!). The
  problem is WHAT variable I can use that contains that information (MISS
  or HIT).
  Is there more documentation on the variables available than what is in
  vcl(7)?
  Or anywhere else for that matter.
 
  Thanks,
 
  Alecs
 
  On Wed, Nov 5, 2008 at 3:10 PM, Per Buer [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED] wrote:
 
  Alecs Henry skrev:
   Hi guys,
  
   Is there a variable that I can print on the response header that
 will
   give me the cache lookup result such as TCP_HIT or TCP_MISS?
 
  I guess you can add the relevant header in vcl_hit and vcl_miss
 
  See the FAQ:
  http://varnish.projects.linpro.no/wiki/FAQ#HowdoIaddaHTTPheader
 
  Just add a
  sub vcl_hit {
   # add code from faq here
  }
 
 
 
  --
  http://linpro.no/ | http://redpill.se/
 
 


 --
 Per Buer - Leder Infrastruktur og Drift - Redpill Linpro
 Telefon: 21 54 41 21 - Mobil: 958 39 117
 http://linpro.no/ | http://redpill.se/


___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Inspect Request bodies?

2008-11-05 Thread Tim Kientzle
Under certain circumstances, I want to inspect the body of a
POST request at the proxy cache.

It don't see any hooks for this in the current Varnish 2.0.1,
but I've skimmed the source and it looks feasible:

  * I'll need code to actually read and store the POST body in memory
(including updates to the PASS handler and other places to
use the in-memory data when it's available)

  * I'll need to add VCL functions to actually analyze the POST body.

The second part looks pretty straightforward.  The VCL engine
seems quite modular and extensible.  Because VCL routines run in
per-request threads, it should be feasible to do more time-consuming
operations using straightforward sequential code.  (I've also looked
at extending Squid or Nginx, but breaking down some of these operations
into the necessary state machines would be rather tedious.)

The first part looks trickier.  Has anyone here tried anything
similar?  Any pointers (particular source files I should pay attention
to or memory-management issues I should keep in mind)?

Finally, has anyone else encountered similar requirements that
might benefit from this?  (I.e., if I do get this to work, is
it worth cleaning up the code to contribute back?)

Of course, if Varnish already provides some of this and I've
simply missed it, then that's even better. ;-)

Cheers,

Tim

P.S.  For the curious, there are two specific issues I'm
exploring:  First, I have an API which prefers GET but supports
POST if the arguments are too long; I'd like to accurately
cache responses to these larger requests.  Second, I've been
exploring request-signing techniques borrowed from OAuth.  Both
of these boil down to computing a hash over all query arguments,
including those in the POST body.  So far, I've been handling
these issues at the app server, but I've got a growing suite
of applications running in that layer and I'd like to move the
redundant code into a common proxy layer, so I've been surveying
existing proxy implementations to see which ones are most amenable
to this kind of extension.

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Frontend caching to multiple sites

2008-11-05 Thread rafailowski
Hi,
For change vcl on the fly, just do:
# varnishadm -T 127.0.0.1:33222 vcl.load vcl_name 
/path/to/your/vcl/varnish.vcl
also look at :
vcl.load configname filename
vcl.inline configname quoted_VCLstring
vcl.use configname
vcl.discard configname
vcl.list
vcl.show configname

or if you want : telnet 127.0.0.1 33222
For the downtime, i don't know exactly but it's very quick.


Alecs Henry wrote:
 Hi Espen,
 
 Thanks for the answer!
 
 Is there a way to accomplish this using different VCLs?
 I ask it because I'm trying to figure out a way to make it automatic. As 
 in if I have a new customer, I'd just fill out a form (with the customer 
 details like domain name, backend server, other configuration) and a 
 little system working under the hood would generate the VCL file, send 
 it to the varnish server and load it.
 
 If I use one VCL file for everybody, how do I reload this VCL when I 
 need to change it? Is it necessary to reload varnish? Would it present 
 downtime?
 
 Thanks!!
 
 Alecs
 
 
 
 On Wed, Nov 5, 2008 at 5:58 AM, Espen Braastad [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:
 
 Alecs Henry wrote:
 
 I want to set up varnish as a reverse proxy/cache to multiple
 customer
 sites.
 As in, I have 10 different customers, each with its own web site
 (domains)
 with their own necessities, compression, cookie, authentication,
 etc; each
 customer is a different setup from the other, so I thought OK!
 Let's use a
 different VCL for each customer and all will be fine.
 
 Bear with me here, I've just started playing with varnish, but
 it seems that
 I can't create a different VCL file for each customer and load
 it in varnish
 (vcl.use ...) as varnish will stop responding for the previous
 site and
 start responding only to the new one (active configuration).
 Meaning, the
 content that is served is only the content from the new site,
 even if using
 the correct domain.
 
 How can I go about setting this up?
 I'm using Varnish 2.0.1, just downloaded and compiled it today.
  
 
 Hi,
 
 You can try something like this in one VCL:
 
 sub vcl_recv {
  if (req.http.host ~ ^(www\.)site1\.com$){
   # foo
  }
 
  if (req.http.host ~ ^(www\.)site2\.com$){
   # bar
  }
 
  if (req.http.host ~ ^(www\.)site3\.com$){
   # baz
  }
 
  # Unknown host
  error 403;
 }
 
 -- 
 mvh
 Espen Braastad,
 +47 21 54 41 37
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 Linpro AS - Ledende på Linux
 
 
 
 
 
 
 ___
 varnish-misc mailing list
 varnish-misc@projects.linpro.no
 http://projects.linpro.no/mailman/listinfo/varnish-misc

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Inspect Request bodies?

2008-11-05 Thread Poul-Henning Kamp
In message [EMAIL PROTECTED], Tim Kientzle wri
tes:

  * I'll need code to actually read and store the POST body in memory
(including updates to the PASS handler and other places to
use the in-memory data when it's available)

We sort of have this as point 15 on our shoppinglist:

(http://varnish.projects.linpro.no/wiki/PostTwoShoppingList)

The crucial point here, is that we want it to be controllable in
VCL, so that people can disable it for GB sized uploads and enable
it for short stuff (or vice versa) if they want.

  * I'll need to add VCL functions to actually analyze the POST body.

To be honest, I would would probably just use the inline C facility
and do it there, than trying to generalize it into a VCL extension.

The first part looks trickier.  Has anyone here tried anything
similar?  Any pointers (particular source files I should pay attention
to or memory-management issues I should keep in mind)?

It's pretty straightforward really:  allocate an (non-hashed)
object, add storage to it and store the contents there.

You can see pretty much all the code you need in cache_fetch.c and
for it to go into the tree as a patch, I would insist that the
code gets generalized so we use the same code in both directions,
rather than have two copies.


-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: TCP_HIT header

2008-11-05 Thread JT Justman
Alecs Henry wrote:
 Hi Per,
 
 Here's what I got:
 -
 vcl.load test /usr/local/etc/varnish/configs/test.vcl
 106 267
 *Variable 'obj.http.X-Cache' not accessible in method 'vcl_miss'.*
 At: (/usr/local/etc/varnish/configs/test.vcl Line 62 Pos 13)
 set obj.http.X-Cache = TCP_MISS from  server.ip;
 --
 VCL compilation failed
 -
 
 It works just fine for vcl_hit though.
 Any ideas?
 

'obj' is only available in 'hit' and 'fetch'. So set it in vcl_fetch.
The only side effect being then your header will be set in the case of a
'pass' as well, which may or may not be what you want.

-- 
[EMAIL PROTECTED]
http://www.endpoint.com
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Inspect Request bodies?

2008-11-05 Thread Tim Kientzle
Thanks, Poul-Henning!  These are exactly the hints I needed.

Agree completely about it being controllable in VCL; my
own environment has a mix of requests of widely-varying sizes
and I certainly don't want this for large uploads.

Tim


On Nov 5, 2008, at 11:37 AM, Poul-Henning Kamp wrote:

 In message [EMAIL PROTECTED], Tim  
 Kientzle wri
 tes:

 * I'll need code to actually read and store the POST body in memory
   (including updates to the PASS handler and other places to
   use the in-memory data when it's available)

 We sort of have this as point 15 on our shoppinglist:

   (http://varnish.projects.linpro.no/wiki/PostTwoShoppingList)

 The crucial point here, is that we want it to be controllable in
 VCL, so that people can disable it for GB sized uploads and enable
 it for short stuff (or vice versa) if they want.

 * I'll need to add VCL functions to actually analyze the POST body.

 To be honest, I would would probably just use the inline C facility
 and do it there, than trying to generalize it into a VCL extension.

 The first part looks trickier.  Has anyone here tried anything
 similar?  Any pointers (particular source files I should pay  
 attention
 to or memory-management issues I should keep in mind)?

 It's pretty straightforward really:  allocate an (non-hashed)
 object, add storage to it and store the contents there.

 You can see pretty much all the code you need in cache_fetch.c and
 for it to go into the tree as a patch, I would insist that the
 code gets generalized so we use the same code in both directions,
 rather than have two copies.


 -- 
 Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
 [EMAIL PROTECTED] | TCP/IP since RFC 956
 FreeBSD committer   | BSD since 4.3-tahoe
 Never attribute to malice what can adequately be explained by  
 incompetence.

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc