Varnish url redirection does not work
georgi.int at gmail.com
georgi.int at gmail.com
Sun Feb 28 16:13:04 CET 2016
Thank you about your reply. I am using varnish 3 and tried the following
configuration:
if (req.http.host ~ "thedomain\.com" && req.url~ "^/disclib/download/")
{ set req.backend = filedownload; set req.http.connection = "close";
return (pipe); }
as I defined befor the backend filedownload, but the result is service
unavailable.
Any other suggestions?
On 02/26/2016 09:45 PM, Paul A. Procacci wrote:
> On Fri, Feb 26, 2016 at 12:01:57PM +0200, georgi.int at gmail.com wrote:
>> Hello,
>> I would like to ask your for help after explaining the case and the
>> infrastructure for this domain. In the varnish configuration I restrict
>> some types of files to be accessed and downloaded and if some customer
>> wants to use this functionality I configure subdomain on it's domain on
>> nginx where these restrictions are not present. Although, my customer
>> do not want to change the links to the new subdomains (which rely on
>> nginx) in it's application and I want to redirect all old urls
>> (domain.com/somedir/download) to the new one - download.thedomain.com,
>> so if someone open the old url it's redirected to the subdomain on
>> nginx and the content to be loaded from nginx, not varnish (as the way
>> cpanel domain forwarder works).
>> The problem is that when I followed and configured the varnish official
>> documentation url guide it just change the url in varnishlog, but the
>> content is again openef from varnish, not nginx, also the url in the
>> browser is not rewritten.
>> My questions are 1) is it possible and if yes how, but if not 2) what
>> workaround can I use?
>> Thank you in advance. I will wait for you reply.
> Hello,
>
> It'd be helpful if you shared the parts of your configuration which perform
> the rewriting of the url.
>
> That aside, in order for the browser to request a differnet resource requires
> a 301 (or similar) to be delivered from varnish or nginx. Here's an example:
>
> #####################################################
> sub vcl_recv
> {
> if(req.http.host ~ "(?i)^nothere\.com$"){
> if(req.url ~ "(i?)^/file\.jpg$") {
> return(synth(750, "http://here.com" + req.url));
> }
> }
> }
>
> sub vcl_synth
> {
> if(resp.status == 750){
> set resp.http.Location = resp.reason;
> set resp.status = 301;
> return (deliver);
> }
> }
> #####################################################
>
> Hope this helps.
>
> ~Paul
More information about the varnish-misc
mailing list