Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

According to the varnish documentation, the regsub method should not result in a 301 redirect. Yet that is what seems to be happening in my case (that is, the url actually changes in the browser).

This is what my config looks like:

sub vcl_recv {
    ...
    set req.url = regsub(req.url, "^/event/([-\w]+)/(.*)/$", "/event/\1");
    ...
}

(/event/testevent/1234/ is redirected to /event/testevent)

Behind, I've got nginx and django varnish -> nginx -> uwsgi -> django

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Oh, I see what happened... Django was appending a slash to the url an doing a redirect.

This does the trick:

set req.url = regsub(req.url, "^/event/([-\w]+)/(.*)/$", "/event/\1/");
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.