Multiple virtual host with different IP's

dhanushka ranasinghe parakrama1282 at gmail.com
Mon Sep 24 16:11:13 CEST 2012


Hi  guys ,

Im using nginx with varnish,  and i have following  two virtual-host *[
content.com, content.org ]  *configuration in nginx

With follwing configuration   varnish only cache the content of the *
content.org * , its not caching the *content.com* , Do i need to define
multiple back-ends for each virtual-hosts, can any one giude me how to do
that .Or do i need to configure  separate Varnish instance for each VHOST.


Im not try to cache the https contents , only http need to cache.


This is my configuration...


Configuration
-------------------

*content.com*
===========

server {
    listen      10.100.1.1:8080;
    server_name   content.com;
    access_log /var/log/nginx/content.com.log;
        root /var/www/content.com;
        expires       14d;
        add_header Cache-Control  public;
  }


server {
    listen      10.100.1.1:443;
    server_name   content.com;
    access_log /var/log/nginx/content.com.log;
        root /var/www/content.com;
        expires       14d;
        add_header Cache-Control  public;

        ssl                 on;
        ssl_certificate     /etc/nginx/ssl/content.pem;
        ssl_certificate_key /etc/nginx/ssl/content.key;


  }


*content.org
============*

 server {
                listen      10.100.1.2:8080 default;
                server_name  cache.org;
                {
                        root   /home/httpd/content.org;
                        autoindex on;
                }
        }

     server {
                listen  10.100.1.2:443;
                ssl    on;
                ssl_certificate    /etc/nginx/ssl/content-org.pem;
                ssl_certificate_key    /etc/nginx/ssl/content-org.key;

                server_name content.org;

                {
                root   /home/httpd/content.org;
                autoindex on;
                }



*This is my  varnish default.vcl
======================*

backend default {
    .host = "10.100.1.2";
    .port = "8080";
}

sub vcl_fetch {
     if (!beresp.cacheable) {
                        unset beresp.http.expires;
                        set beresp.http.cache-control = "max-age=900";
                        set beresp.ttl = 1w;
                        set beresp.http.magicmarker = "1";
         return (pass);
     }
     if (beresp.http.Set-Cookie) {
         return (pass);
     }
     return (deliver);
 }
 sub vcl_deliver {
     return (deliver);
 }





Thanks in advance


Thank You
Dhanushka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120924/fe735f79/attachment.html>


More information about the varnish-misc mailing list