How to extract the protocol part of URL from an apache request
How to extract the protocol part of URL from an apache request
am 17.09.2008 09:21:52 von grsvarma019
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-UR L-from-an-apache-request-tp19526642p19526642.html
Sent from the mod_perl - General mailing list archive at Nabble.com.
Re: How to extract the protocol part of URL from an apache request
am 17.09.2008 09:34:40 von Ryan Gies
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();
Re: How to extract the protocol part of URL from an apache request
am 17.09.2008 10:09:23 von torsten.foertsch
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@gmx.net
Re: How to extract the protocol part of URL from an apache request
am 17.09.2008 10:32:17 von John ORourke
This is a multi-part message in MIME format.
--------------010702010601070701010602
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
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
--------------010702010601070701010602
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Torsten Foertsch wrote:
type="cite">
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
--------------010702010601070701010602--
Re: How to extract the protocol part of URL from an apache request
am 17.09.2008 10:36:58 von torsten.foertsch
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. =A0I used the following to inject a
> header on the proxy:
>
> =A0 =A0 =A0 =A0 SetEnv SCHEME http
> =A0 =A0 =A0 =A0 RewriteCond %{HTTPS} on
> =A0 =A0 =A0 =A0 RewriteRule ^(.*) $1 [E=3DSCHEME:https]
Yes, I think that should work as well without the reverse proxy.=20
Mod_rewrite talks directly to mod_ssl.
Torsten
=2D-
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net