2016-03-24 13 views
2

Entschuldigung, ich bin neu in Varnish.Wie auf spezifische URL umleiten - Varnish?

Ich versuche Haufen Zeug in meinem /etc/varnish/mysite.vlc aber kann es nicht funktionieren.

Ich möchte auf bestimmte URL auf eine andere URL umleiten. Beispiel: Wenn jemand Zugang http://mysite1/thepage1.xml es http://mysite2/thepage2.xml

varnishd -V 
varnishd (varnish-3.0.5 revision 1a89b1f) 
Copyright (c) 2006 Verdens Gang AS 
Copyright (c) 2006-2011 Varnish Software AS 

Jede Hilfe würde geschätzt gehen sollte.

Antwort

3

Wie in Lack 3

sub vcl_recv { 
    if (req.url~ "^/thepage1.xml?$") { 
    error 750 "http://mysite2/thepage2.xml"; 
    } 
} 

sub vcl_error { 
    if (obj.status == 750) { 
    set obj.http.Location = obj.response; 
    set obj.status = 301; 
    return(deliver); 
    } 
} 

Wie umleiten in Lack 4

sub vcl_recv { 
    if (req.url~ "^/thepage1.xml?$") { 
    return (synth (750, "http://mysite2/thepage2.xml")); #This throws a synthetic page so the request won't go to the backend 
    } 
} 

sub vcl_synth { 
    if (resp.status == 750) { 
    set resp.http.Location = resp.reason; 
    set resp.status = 301; 
    return(deliver); 
    } 
} 
+0

Vielen Dank für Ihre Hilfe umleiten. – whitesiroi