[imp] Possible problem with virtual host and IMP 3.1 or Horde 2.1 or maybe with me :)

Joe Burks joe-imp at wavicle.org
Wed Jan 1 15:32:26 PST 2003


About 3 weeks ago I got IMP set up on my server and it worked flawlessly... 
until today...  It is trying to bring up the maintenance page so I can 
archive all my received email, but is generating the url for the account 
maintenance page wrong.  Here's a run down on my setup:

Apache 2.0.43, PHP 4.2.3, IMP 3.1, Horde 2.1

I created a DNS entry called webmail.wavicle.org
I created an apache virtual host entry for webmail.wavicle.org that points 
to my imp installation directory
Inside horde/config/registry.php:
   I changed the horde webroot to 'http://www.wavicle.org/horde'
   I changed the imp webroot to ''

* Note that the horde webroot is a full path.  If the horde webroot is not 
a full path, there are attempted accesses to 'webmail.wavicle.org/horde' 
which doesn't exist, this creates a problem with the style sheets at a minimum.

Again, this set up has worked, flawlessly, for weeks.  Today, I can't get 
to webmail.  After logging in, I'm getting a 404 error.  The webmail error 
log contains:

[Wed Jan 01 13:53:37 2003] [error] [client 64.166.42.132] File does not 
exist: /web/htdocs/horde/imp/http:, referer: 
http://webmail.wavicle.org/login.php?Horde=[session]

and the access log contains:

64.166.42.132 - - [01/Jan/2003:13:53:37 -0800] "GET 
/http://www.wavicle.org/horde/maintenance.php?Horde=[session]&module=imp&getvars=Horde%[session] 
HTTP/1.1" 404 321

So between those two webroots, a url was created that looks like:

http://webmail.wavicle.org/http://www.wavicle.org/horde/[...]

I eventually tracked down the guy creating the url to 
horde/lib/Maintenance.php line 162 who calls the Horde::url() function 
specifying "create a full path" (second parameter is 'true').  So I looked 
at horde/lib/Horde.php, and if I follow the logic there is the source of 
the bad url generated.  So I made a small change at line 683 of Horde.php from:

         if ($full) {

to:

         if ($full && (substr($uri,0,7) != 'http://')) {

and I was able to get to the maintenance page...  Now the problem is that 
the maintenance page attempts, when any button is pressed, to use an imp 
uri from the different host name (it tries to access 
http://www.wavicle.org/redirect.php instead of 
http://webmail.wavicle.org/redirect.php).  To fix this, I changed the imp 
webroot from '' (empty) to 'http://webmail.wavicle.org'.  Unfortunately the 
url() function gets me again, as imp/index.php tries to create a full url 
to redirect.php - so I dig in to Horde.php again and change url() line 307 
(or thereabouts):

              $url = $protocol . '://' . $server_name;

to:

             $url = '';
             if ( substr($webroot,0,7) != 'http://' ) {
                 $url = $protocol . '://' . $server_name;
             }

And now everything appears to be working.

That said...  I'm not really a PHP programmer, so I'm sure there are some 
shortcomings to the way I did that (will HTTP:// throw it off?  Is it case 
sensitive?).  But I'm also sure I'm not the first person to do this sort of 
virtual host thing...  I didn't do the best search over the list archives, 
but is there a way to fix this that doesn't involve changing Horde code and 
doesn't involve a recursive symlink (I'm sure I could have solved this by 
symlinking /horde to /horde/imp/horde and making the horde webroot '/horde' 
but that just looked bad to me).

-Joe



More information about the imp mailing list