haproxy / apache / tomcat – 没有结尾斜杠导致301redirect

我有这样的configuration:

haproxy(80,443) – > httpd(8443) – > tomcat(8096)

转到https://websrv1/test将导致301redirect到haproxy应该代理请求的httpd端口。 所以用户被redirect到http://websrv1:8443/test

但是,如果用户转到https://websrv1/test/ - specifying a the trailing slash – 它工作得很好。

当用户不指定尾部斜线时,如何防止发生这种redirect?

  • haproxyconfiguration?
  • Apache的url重写?
  • tomcat url重写?

问题在于Apache级别。

你可以尝试设置

 UseCanonicalName On 

 ServerName websrv1:80 

在你的Apacheconfiguration中使apache使用正确的重写。

或者,您可以禁用重写斜线

 DirectorySlash Off 

请参阅UseCanonicalName , ServerName和DirectorySlash