作为Apache2服务器的反向代理清除端口redirect问题

我一直在寻找,也有很多人有同样的问题,但没有一个明确的解决scheme(或者至less我没有find它)。

我正在使用Varnish-Cache(3.0)作为侦听端口88中的Apache 2 Web服务器的端口80上的反向代理

如果我请求下面的URL,它工作正常: http:// server / stuff /

但是,如果我请求: http:// server / stuff (最后没有“/”),浏览器被redirect到后端Apache( http:// server:88 / stuff / )的端口。

如何在这种情况下设置Apache 2的行为?

提前致谢!

检查httpd.conf上的UseCanonicalName指令

# # UseCanonicalName: Determines how Apache constructs self-referencing # URLs and the SERVER_NAME and SERVER_PORT variables. # When set "Off", Apache will use the Hostname and Port supplied # by the client. When set "On", Apache will use the value of the # ServerName directive. # UseCanonicalName Off 

你也可以去除清漆,试试这个:

 sub vcl_fetch { if (beresp.status == 301 || beresp.status == 302) { set beresp.http.Location = regsub(beresp.http.Location, "^(\w+://[^/]+):\d+", "\1"); } }