[Rt-devel] [PATCH] ProxyPass and 3.6.1 redirect function

Michael Brader michael at youramigo.com
Fri Aug 18 01:33:30 EDT 2006


Hi,

We have RT set up behind a proxy ie.

<VirtualHost *:80>
    ServerName rt.youramigo.com
    ...
    ProxyPass / http://rtdb.bc.youramigo.com:8078/
</VirtualHost>

After upgrading to 3.6.1 the redirect function in RT::Interface::Web
was exposing the internal URL rather than rt.youramigo.com.

A quick look through RT_Config.pm didn't turn up anything that looked
appropriate so I made the following changes in our codebase which have
solved the problem here.

I'm sending the patch in case it's useful for anyone else running RT
in this manner. Just set $UseCanonicalRedirect to 1 in
etc/RT_SiteConfig.pm

Cheers,
Michael Brader

--- build/etc/RT_Config.pm	2006-08-18 01:34:39.000000000 +0000
+++ rt3/etc/RT_Config.pm	2006-08-18 04:00:50.000000000 +0000
@@ -344,6 +344,11 @@ Set($WebBaseURL , "http://localhost:$Web
 
 Set($WebURL , $WebBaseURL . $WebPath . "/");
 
+# If $UseCanonicalRedirect is true and the user is coming in via a
+# non-canonical hostname, redirect them to the canonical host,
+# Otherwise use $ENV{'HTTP_HOST'} and $ENV{'SERVER_PORT'}.
+Set( $UseCanonicalRedirect, 0 );
+
 # $WebImagesURL points to the base URL where RT can find its images.
 
 Set($WebImagesURL , $WebPath . "/NoAuth/images/");

--- build/lib/RT/Interface/Web.pm	2006-07-25 23:44:13.000000000 +0000
+++ rt3/lib/RT/Interface/Web.pm	2006-08-18 04:01:03.000000000 +0000
@@ -187,14 +187,18 @@ sub Redirect {
     my $uri = URI->new($redir_to);
     my $server_uri = URI->new($RT::WebURL);
 
-    # If the user is coming in via a non-canonical
-    # hostname, don't redirect them to the canonical host,
-    # it will just upset them (and invalidate their credentials)
-    if ($uri->host  eq $server_uri->host && 
-        $uri->port eq $server_uri->port) {
-            $uri->host($ENV{'HTTP_HOST'});
-            $uri->port($ENV{'SERVER_PORT'});
-        }
+    unless ($RT::UseCanonicalRedirect) {
+
+	# If the user is coming in via a non-canonical
+	# hostname, don't redirect them to the canonical host,
+	# it will just upset them (and invalidate their credentials)
+
+	if ($uri->host  eq $server_uri->host && 
+	    $uri->port eq $server_uri->port) {
+	    $uri->host($ENV{'HTTP_HOST'});
+	    $uri->port($ENV{'SERVER_PORT'});
+	}
+    }
 
     $HTML::Mason::Commands::m->redirect($uri->canonical);
     $HTML::Mason::Commands::m->abort;

-- 
Michael Brader                          michael.brader at youramigo.com



More information about the Rt-devel mailing list