Why is Varnish redirecting as 301?

夙愿已清 提交于 2019-12-13 06:28:35

问题


I have been deploying a mediawiki docker container (appscontainer/mediawiki) based on Apache2 on a VPS, and I put a fresh install of Varnish on top of it, to be able to proxied different subdomains to the proper applications on the same server.

My current default.vcl configuration file look like the following:

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

backend wikimedia {
 .host = "localhost";
 .port = "8080";
}

sub vcl_recv {
  if(req.http.host == "wiki.virtual-assembly.org") {
    set req.backend_hint = wikimedia;
  }

  set req.backend_hint = default;
}

My issue is that when I request the URL http://wiki.virtual-assembly.org, I got redirected via a 301 to the IP adress of the server on port 8080 (port on which the apache2 instance is listening).

Is there a way to tell Varnish to keep the location to be http://wiki.virtual-assembly.org, or is it an apache2 misconfiguration ?

Thanks in advance,

PS: I know my two backends are equivalent, I will change the default in the future when I will have deployed more apps.


回答1:


Shot in the dark answer. Do you still get a 301 if you put the default backend_req into an else statement instead of outside the if?



来源:https://stackoverflow.com/questions/37480807/why-is-varnish-redirecting-as-301

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!