Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

How to extract the protocol part of URL from an apache request

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


grsvarma019 at gmail

Sep 17, 2008, 12:21 AM

Post #1 of 5 (622 views)
Permalink
How to extract the protocol part of URL from an apache request

Hi,

I am using mod_perl for authentication.

I could able to extract the Host and path information of the currect URL
using apache request object.
like $apache->header_in(Host) and $apache->uri respectively.

But , i couldn't find how to extract the protocol(http or https ) from the
current URL using apache request object.

Can you please anybody help me in this?

Thanks,
Raja
--
View this message in context: http://www.nabble.com/How-to-extract-the-protocol-part-of-URL-from-an-apache-request-tp19526642p19526642.html
Sent from the mod_perl - General mailing list archive at Nabble.com.


ryan at livesite

Sep 17, 2008, 12:34 AM

Post #2 of 5 (598 views)
Permalink
Re: How to extract the protocol part of URL from an apache request [In reply to]

On Wed, 17 Sep 2008 00:21:52 -0700 (PDT)
grsvarma019 wrote:

> But , i couldn't find how to extract the protocol(http or https )
> from the current URL using apache request object.
> Can you please anybody help me in this?

See: perldoc Apache2::RequestRec

# HTTP protocol version number
$proto_num = $r->proto_num();


torsten.foertsch at gmx

Sep 17, 2008, 1:09 AM

Post #3 of 5 (599 views)
Permalink
Re: How to extract the protocol part of URL from an apache request [In reply to]

On Wed 17 Sep 2008, grsvarma019 wrote:
> But , i couldn't find how to extract the protocol(http or https )

There are Apache2::ModSSL and Apache::SSLLookup on CPAN in case you need
that information in a request phase prior to the ResponseHandler.
Mod_ssl can be configured to export SSL information as environment
variables. Those can be looked up in a ResponseHandler via
$r->subprocess_env.

Further, if you are unable to install an XS module (precompiled
mod_perl+apache on windows without C compiler for instance) and you
need SSL information prior to the response phase you can issue a
subrequest to get it. Not the fastest way but it works. I have
described that technique in a previous mail to the list this or last
year.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch [at] gmx


john-modperl at o-rourke

Sep 17, 2008, 1:32 AM

Post #4 of 5 (596 views)
Permalink
Re: How to extract the protocol part of URL from an apache request [In reply to]

Torsten Foertsch wrote:
> On Wed 17 Sep 2008, grsvarma019 wrote:
>
>> But , i couldn't find how to extract the protocol(http or https )
>>
>
> There are Apache2::ModSSL and Apache::SSLLookup on CPAN in case you need
> that information in a request phase prior to the ResponseHandler.
>
I had the same problem but the machine serving the request had a reverse
proxy in front of it. I used the following to inject a header on the proxy:

SetEnv SCHEME http
SetEnv HOST localhost
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule ^(.*) $1 [E=SCHEME:https]
RewriteCond %{HTTP_HOST} ^(.*)$
RewriteRule ^(.*) $1 [PT,E=HOST:%1]
RequestHeader set X-Absolute-URI %{SCHEME}e://%{HOST}e

That gives you a header containing the protocol and host.

hth,
John


torsten.foertsch at gmx

Sep 17, 2008, 1:36 AM

Post #5 of 5 (592 views)
Permalink
Re: How to extract the protocol part of URL from an apache request [In reply to]

On Wed 17 Sep 2008, John ORourke wrote:
> I had the same problem but the machine serving the request had a
> reverse proxy in front of it.  I used the following to inject a
> header on the proxy:
>
>         SetEnv SCHEME http
>         RewriteCond %{HTTPS} on
>         RewriteRule ^(.*) $1 [E=SCHEME:https]

Yes, I think that should work as well without the reverse proxy.
Mod_rewrite talks directly to mod_ssl.

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch [at] gmx

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.