You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stas Bekman <st...@stason.org> on 2001/08/01 05:16:33 UTC

Re: Bug??

On Tue, 31 Jul 2001, Chris Rodgers wrote:

> Thanks for that. However, I've already seen this. The problem is that I'm
> requesting pages at:
>
> http://my.server.com/perl/blah.pl
>
> and also
>
> https://my.server.com/perl/blah.pl
>
> Now these should be different scripts, and Apache is set up with a
> completely different document and perl root for the http and https
> servers. Unfortunately, these still get confused, even with the
> NameWithVirtualHost code. Hence, I thought of hacking the .pm files to
> include the server port as well as the name in the uniquely generated
> namespace.
>
> Any other ideas??

Hmm, I think you are the first one to hit this issue. Try this (untested):

--- ./lib/Apache/Registry.pm.orig	Wed Aug  1 11:06:49 2001
+++ ./lib/Apache/Registry.pm	Wed Aug  1 11:11:04 2001
@@ -70,7 +70,8 @@

 	if ($Apache::Registry::NameWithVirtualHost &&
$r->server->is_virtual) {
 	    my $name = $r->get_server_name;
-	    $script_name = join "", $name, $script_name if $name;
+	    $script_name = join "", (exists $ENV{HTTPS}?'https':''),
+                $name, $script_name if $name;
 	}

 	# Escape everything into valid perl identifiers

based on the earlier discussion about detecting https :)

> Yours,
>
> Chris Rodgers
> christopher.rodgers@sjc.ox.ac.uk
>
> On Tue, 31 Jul 2001, Stas Bekman wrote:
>
> > On Tue, 31 Jul 2001, Chris Rodgers wrote:
> >
> > > Hi,
> > >
> > > I'm running Apache with mod_perl and mod_ssl. ("Apache/1.3.20 (Unix)
> > > mod_perl/1.25 mod_ssl/2.8.4 OpenSSL/0.9.5a" to be precise.)
> > >
> > > I am listening on both port 80 (HTTP) and port 443 (HTTPS) and serving perl
> > > scripts. There are two separate vhosts on the two ports -> i.e. entirely
> > > different websites, but only one httpd (and associated set of children).
> > >
> > > Now, this works fine, except that if I try to access a script with the same
> > > name on the http site and the https site, I get the WRONG version sometimes.
> > > I think that this is because mod_perl is only using the server name (and not
> > > the port / protocol) when it builds its table for caching scripts.
> > >
> > > Does anyone know how to fix this? I was thinking of editing all the .pm
> > > files for mod_perl around where they refer to $NameWithVirtualHost - and to
> > > add the port onto the begining of the unique identifier which is used to
> > > form the namespace for each script. Would this work - or might it break
> > > something else??!
> > >
> > > Any hints/tips would be greatly appreciated!
> >
> > http://perl.apache.org/guide/multiuser.html#Virtual_Hosts_in_the_guide
> >
> >
> > _____________________________________________________________________
> > Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
> > http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
> > mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
> > http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
> >
> >
> >
>



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Re: Bug??

Posted by Tatsuhiko Miyagawa <mi...@edge.co.jp>.
On Wed, 1 Aug 2001 13:12:44 +0200
"Issac Goldstand" <is...@mail.jct.ac.il> wrote:

> > based on the earlier discussion about detecting https :)
> 
> That will take care of standard http/https, but what if we have a custom
> client connecting on weird ports _without_ putting the port in the URL?
> Wouldn't it make sense to just take $ENV{SERVER_PORT} and join() _that_ to
> make the unique filename?  That'll take care of all the weird server
> combinations possible including SSL, as only one listening socket can
> physically bind to a port.  It'll even transparently take care of weird
> back-end server problems, as no matter how many servers seem to be on
> http://frontend:80, the backends MUST be unique combinations of either
> different hostnames or different ports...

Agreed here.

We've tried to set up development/production environment in the
same one server with config like following (simplified):

  Listen 80    # production
  Listen 8080  # development

  <VirtualHost _default_:80>
  DocumentRoot /home/production
  </VirtualHost>

  <VirtualHost _default_:8080>
  DocumentRoot /home/development
  </VirtualHost>


Yeah, this will lead to mixups of the following two URLs, which we
don't want.

  http://hostname/foo.cgi      = /home/prodution/foo.cgi
  http://hostname:8080/foo.cgi = /home/environment/foo.cgi
 

Patch follows, or do we have to make our own PortAwareRegistry
which inherits from Apache::RegistryNG ?

Thanks.


--- Registry.pm.orig    Wed Aug 15 19:17:42 2001
+++ Registry.pm Wed Aug 15 19:18:19 2001
@@ -70,7 +70,7 @@

        if ($Apache::Registry::NameWithVirtualHost && $r->server->is_virtual) {
            my $name = $r->get_server_name;
-           $script_name = join "", $name, $script_name if $name;
+           $script_name = join "", $name, $r->get_server_port, $script_name if $name;
        }

        # Escape everything into valid perl identifiers



--
Tatsuhiko Miyagawa
mailto:miyagawa@cpan.org


Re: Bug??

Posted by Issac Goldstand <is...@mail.jct.ac.il>.
----- Original Message -----
From: "Stas Bekman" <st...@stason.org>
To: "Chris Rodgers" <ch...@st-johns.oxford.ac.uk>
Cc: <mo...@apache.org>
Sent: Wednesday, August 01, 2001 05:16
Subject: Re: Bug??


> On Tue, 31 Jul 2001, Chris Rodgers wrote:
>
> > Thanks for that. However, I've already seen this. The problem is that
I'm
> > requesting pages at:
> >
> > http://my.server.com/perl/blah.pl
> >
> > and also
> >
> > https://my.server.com/perl/blah.pl
> >
> > Now these should be different scripts, and Apache is set up with a
> > completely different document and perl root for the http and https
> > servers. Unfortunately, these still get confused, even with the
> > NameWithVirtualHost code. Hence, I thought of hacking the .pm files to
> > include the server port as well as the name in the uniquely generated
> > namespace.
> >
> > Any other ideas??
>
> Hmm, I think you are the first one to hit this issue. Try this (untested):
>
> --- ./lib/Apache/Registry.pm.orig Wed Aug  1 11:06:49 2001
> +++ ./lib/Apache/Registry.pm Wed Aug  1 11:11:04 2001
> @@ -70,7 +70,8 @@
>
>   if ($Apache::Registry::NameWithVirtualHost &&
> $r->server->is_virtual) {
>       my $name = $r->get_server_name;
> -     $script_name = join "", $name, $script_name if $name;
> +     $script_name = join "", (exists $ENV{HTTPS}?'https':''),
> +                $name, $script_name if $name;
>   }
>
>   # Escape everything into valid perl identifiers
>
> based on the earlier discussion about detecting https :)

That will take care of standard http/https, but what if we have a custom
client connecting on weird ports _without_ putting the port in the URL?
Wouldn't it make sense to just take $ENV{SERVER_PORT} and join() _that_ to
make the unique filename?  That'll take care of all the weird server
combinations possible including SSL, as only one listening socket can
physically bind to a port.  It'll even transparently take care of weird
back-end server problems, as no matter how many servers seem to be on
http://frontend:80, the backends MUST be unique combinations of either
different hostnames or different ports...

Just my $0.02

  Issac

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B