[Rt-commit] rt branch, 4.0/tweak-validate-web-config-check, created. rt-4.0.4-215-g4761629

? sunnavy sunnavy at bestpractical.com
Fri Jan 20 07:39:11 EST 2012


The branch, 4.0/tweak-validate-web-config-check has been created
        at  476162950d38b9a8f4a825cdbccd0a96ec2d87f3 (commit)

- Log -----------------------------------------------------------------
commit 476162950d38b9a8f4a825cdbccd0a96ec2d87f3
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jan 20 20:25:41 2012 +0800

    consider reverse proxy case

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 39c0c8c..9973f09 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1090,18 +1090,20 @@ sub ValidateWebConfig {
         $RT::Logger->warn("The actual SERVER_PORT ($ENV{SERVER_PORT}) does NOT match the configured WebPort ($RT::WebPort). Perhaps you should Set(\$WebPort, $ENV{SERVER_PORT}); in RT_SiteConfig.pm, otherwise your internal links may be broken.");
     }
 
-    if ($ENV{HTTP_HOST}) {
-        # match "example.com" or "example.com:80"
-        my ($host) = $ENV{HTTP_HOST} =~ /^(.*?)(:\d+)?$/;
+    my $host =
+         $ENV{HTTP_X_FORWARDED_HOST}
+      || $ENV{HTTP_X_FORWARDED_SERVER};
 
-        if ($host ne RT->Config->Get('WebDomain')) {
-            $RT::Logger->warn("The actual HTTP_HOST ($host) does NOT match the configured WebDomain ($RT::WebDomain). Perhaps you should Set(\$WebDomain, '$host'); in RT_SiteConfig.pm, otherwise your internal links may be broken.");
-        }
+    if ( !$host && $ENV{HTTP_HOST} ) {
+        ($host) = $ENV{HTTP_HOST} =~ /^(.*?)(:\d+)?$/;
     }
-    else {
-        if ($ENV{SERVER_NAME} ne RT->Config->Get('WebDomain')) {
-            $RT::Logger->warn("The actual SERVER_NAME ($ENV{SERVER_NAME}) does NOT match the configured WebDomain ($RT::WebDomain). Perhaps you should Set(\$WebDomain, '$ENV{SERVER_NAME}'); in RT_SiteConfig.pm, otherwise your internal links may be broken.");
-        }
+
+    $host ||= $ENV{SERVER_NAME};
+
+    if ( $host ne RT->Config->Get('WebDomain') ) {
+        $RT::Logger->warn(
+"The actual host ($host) does NOT match the configured WebDomain ($RT::WebDomain). Perhaps you should Set(\$WebDomain, '$host'); in RT_SiteConfig.pm, otherwise your internal links may be broken."
+        );
     }
 
     if ($ENV{SCRIPT_NAME} ne RT->Config->Get('WebPath')) {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list