为什么将Varnish重定向为301? [英] Why is Varnish redirecting as 301?
问题描述
我一直在VPS上部署基于Apache2的mediawiki docker容器(appscontainer/mediawiki),并在其上重新安装了Varnish,以便能够将不同的子域代理到同一应用程序上的适当应用程序服务器.
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.
我当前的default.vcl配置文件如下所示:
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;
}
我的问题是,当我请求URL http://wiki.virtual-assembly.org ,我通过301重定向到端口8080(apache2实例正在监听的端口)上服务器的IP地址.
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).
是否可以告诉Varnish将位置保持为 http://wiki.virtual-assembly.org ,还是apache2配置错误?
Is there a way to tell Varnish to keep the location to be http://wiki.virtual-assembly.org, or is it an apache2 misconfiguration ?
预先感谢
PS::我知道我的两个后端是等效的,以后我将在部署更多应用程序时更改默认值.
PS: I know my two backends are equivalent, I will change the default in the future when I will have deployed more apps.
推荐答案
暗中回答.如果将默认的backend_req放入else语句而不是if之外,还会得到301吗?
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?
这篇关于为什么将Varnish重定向为301?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!