You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by André Warnier <aw...@ice-sa.com> on 2012/11/24 16:58:50 UTC
get the incoming TCP protocol type
Hi.
Inside a mod_perl2 request handler, how can I find out if the current request was received
via HTTP or HTTPS ?
I mean :
The client (browser e.g.) gets a URL "http://host.x.y/path1/path2..", and
- translates host.x.y to an IP
- makes a connection to that IP (and port)
- sends a request like :
GET /path1/path2.. HTTP/1.1
Host: host.x.y
...
OR
The client (browser e.g.) gets a URL "https://host.x.y/path1/path2..", and
- translates host.x.y to an IP
- makes an *SSL* connection to that IP (and port)
- sends a request like :
GET /path1/path2.. HTTP/1.1
Host: host.x.y
...
and
Inside a handler, I can get
$r->hostname ==> host.x.y
$r->uri and $r->unparsed_uri ==> /path1/path2..
and I can also get the port on which the request was received (presumably), via
$r->get_server_port
but that is not really a guarantee, any port could be set for either HTTP or HTTPS.
and then I see
$r->proto and $r->proto_num
but these are relative to the protocol string as it appears in the first request line, not
to the type of connection that was used for the request.
And in the request, I guess it would always be HTTP/1.1, or ?
(I don't have a HTTPS host right now to check this)
And I haven't really found anything yet in Apache2:RequestRec, Apache2::Connection or
Apache2::ServerRec which would provide that information.
Is there somewhere a "is_secure()" or something which provides that ?
Or can I rely on the presence/absence of some request header ?
Help..
The point is, I'd like to write the handler once, and use it inside a HTTP or a HTTPS host
indifferently. And if possible, I'd also like to avoid having to tell the handler where
he lives via some PerlSetVar just for that.
But maybe that's the easiest solution ?
Re: get the incoming TCP protocol type
Posted by Ryan Gies <ry...@livesite.net>.
On 11/24/2012 10:58 AM, André Warnier wrote:
> Hi.
>
> Inside a mod_perl2 request handler, how can I find out if the current
> request was received via HTTP or HTTPS ?
Have you looked into:
$r->scheme; # Will return 'http' or 'https'
Maybe you want to set environment variables:
http://httpd.apache.org/docs/2.2/mod/mod_ssl.html
Could dig into the server config, looking for 'SSLEngine' eq 'on':
my $tree = Apache2::Directive::conftree(); # Not sure how to distill a
tree for the 'current request'
my @nodes = $tree->lookup('SSLEngine');
Note that if you're sitting behind a reverse-proxy, it will be the one
negotiating SSL with the client.
Note that one can form urls such as "//www.example.com" and the browser
will use the protocol which served the page.
>
> I mean :
> The client (browser e.g.) gets a URL "http://host.x.y/path1/path2..", and
> - translates host.x.y to an IP
> - makes a connection to that IP (and port)
> - sends a request like :
> GET /path1/path2.. HTTP/1.1
> Host: host.x.y
> ...
>
> OR
> The client (browser e.g.) gets a URL "https://host.x.y/path1/path2..",
> and
> - translates host.x.y to an IP
> - makes an *SSL* connection to that IP (and port)
> - sends a request like :
> GET /path1/path2.. HTTP/1.1
> Host: host.x.y
> ...
>
> and
>
> Inside a handler, I can get
> $r->hostname ==> host.x.y
> $r->uri and $r->unparsed_uri ==> /path1/path2..
>
> and I can also get the port on which the request was received
> (presumably), via
> $r->get_server_port
> but that is not really a guarantee, any port could be set for either
> HTTP or HTTPS.
>
> and then I see
> $r->proto and $r->proto_num
> but these are relative to the protocol string as it appears in the
> first request line, not to the type of connection that was used for
> the request.
> And in the request, I guess it would always be HTTP/1.1, or ?
> (I don't have a HTTPS host right now to check this)
>
> And I haven't really found anything yet in Apache2:RequestRec,
> Apache2::Connection or Apache2::ServerRec which would provide that
> information.
>
> Is there somewhere a "is_secure()" or something which provides that ?
> Or can I rely on the presence/absence of some request header ?
>
> Help..
>
>
> The point is, I'd like to write the handler once, and use it inside a
> HTTP or a HTTPS host indifferently. And if possible, I'd also like to
> avoid having to tell the handler where he lives via some PerlSetVar
> just for that.
> But maybe that's the easiest solution ?
>
Re: get the incoming TCP protocol type
Posted by André Warnier <aw...@ice-sa.com>.
Torsten Förtsch wrote:
> On 11/26/2012 09:05 AM, André Warnier wrote:
>> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
>>
>> there is apparently a "server variable" HTTPS which can be tested in a
>> RewriteCond, and which looks just like what I need :
>>
>> HTTPS
>> Will contain the text "on" if the connection is using SSL/TLS, or
>> "off" otherwise. (This variable can be safely used regardless of whether
>> or not mod_ssl is loaded).
>>
>> Now I just have to find out how I can actually access such a "server
>> variable" inside a mod_perl handler. But that should be a breeze,
>> considering the nice online mod_perl documentation, right ?
>> Let's see if I can beat Torsten to it..
>
> The problem is this "variable" is not something that is stored along
> with the other request data. It is just the temporary result of a
> function call.
>
> What mod_rewrite does here to provide the "variable" is 2 things:
>
> 1) it looks for an optional function (this is a thing APR has invented)
> named "ssl_is_https". In C it looks something like this:
>
> APR_OPTIONAL_FN_TYPE(ssl_is_https) *is_https;
> is_https=APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
>
> If the function cannot be found HTTPS will be off because mod_ssl is not
> loaded.
>
> 2) then it calls the function, which returns a boolean value.
>
> Apache2::ModSSL does exactly the same.
>
>
> To make this variable accessible by means of mod_rewrite to mod_perl you
> can:
>
> RewriteCond %{HTTPS} =on
> RewriteRule .? - E=HTTPS:42
>
> Later on in Perl you can ask
>
> if ($r->subprocess_env->{HTTPS} eq "42") ...
>
>
> Mod_rewrite normally works in the uri translation phase, except when it
> is called in a <Directory>, <Location> or <Files> block or a .htaccess
> file. In this case it works in the fixup phase. Unfortunately,
> mod_rewrite installs its handler with APR_HOOK_FIRST priority while
> mod_perl uses APR_HOOK_REALLY_FIRST. That means a PerlFixupHandler is
> called *before* mod_rewrite in directory context.
>
Between the two of you, we're seeing the light at the end of the tunnel..
Many thanks. I don't think that this is really documented anywhere, so my chances of
finding this by myself were rather low to begin with.
I must say that I slightly prefer Torsten's solution, which looks easier (some of the URLs
to proxy already have a query string, for instance).
But I can see also that I'll have to seriously document this in the code, otherwise some
poor maintainer is going to have a hard time in a couple of years from now, trying to
figure out what is going on here. Specially if he has never heard of Deep Thought.
Re: get the incoming TCP protocol type
Posted by Torsten Förtsch <to...@gmx.net>.
On 11/26/2012 09:05 AM, André Warnier wrote:
>
> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
>
> there is apparently a "server variable" HTTPS which can be tested in a
> RewriteCond, and which looks just like what I need :
>
> HTTPS
> Will contain the text "on" if the connection is using SSL/TLS, or
> "off" otherwise. (This variable can be safely used regardless of whether
> or not mod_ssl is loaded).
>
> Now I just have to find out how I can actually access such a "server
> variable" inside a mod_perl handler. But that should be a breeze,
> considering the nice online mod_perl documentation, right ?
> Let's see if I can beat Torsten to it..
The problem is this "variable" is not something that is stored along
with the other request data. It is just the temporary result of a
function call.
What mod_rewrite does here to provide the "variable" is 2 things:
1) it looks for an optional function (this is a thing APR has invented)
named "ssl_is_https". In C it looks something like this:
APR_OPTIONAL_FN_TYPE(ssl_is_https) *is_https;
is_https=APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
If the function cannot be found HTTPS will be off because mod_ssl is not
loaded.
2) then it calls the function, which returns a boolean value.
Apache2::ModSSL does exactly the same.
To make this variable accessible by means of mod_rewrite to mod_perl you
can:
RewriteCond %{HTTPS} =on
RewriteRule .? - E=HTTPS:42
Later on in Perl you can ask
if ($r->subprocess_env->{HTTPS} eq "42") ...
Mod_rewrite normally works in the uri translation phase, except when it
is called in a <Directory>, <Location> or <Files> block or a .htaccess
file. In this case it works in the fixup phase. Unfortunately,
mod_rewrite installs its handler with APR_HOOK_FIRST priority while
mod_perl uses APR_HOOK_REALLY_FIRST. That means a PerlFixupHandler is
called *before* mod_rewrite in directory context.
Torsten
Re: get the incoming TCP protocol type
Posted by Vincent Veyron <vv...@wanadoo.fr>.
e lundi 26 novembre 2012 à 09:05 +0100, André Warnier a écrit :
> Vincent Veyron wrote:
> > Le samedi 24 novembre 2012 à 16:58 +0100, André Warnier a écrit :
> >
> >> Is there somewhere a "is_secure()" or something which provides that ?
> >> Or can I rely on the presence/absence of some request header ?
> >>
> >
> >
> > Apache's mod_rewrite has the HTTPS RewriteCond directive, which I use to
> > enforce https access on a site like so:
> >
> > RewriteCond %{HTTPS} off
> >
> > RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
> >
> > May be you can use this to mark the request somehow?
> >
>
> My problem is slightly different : I don't need to "enforce" HTTPS on the requests which I
> proxy; I need to determine if the incoming request was made via HTTPS.
>
> But your tip above actually pointed to something which may be of use to me : in
>
> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
>
> there is apparently a "server variable" HTTPS which can be tested in a RewriteCond, and
> which looks just like what I need :
>
> HTTPS
Well, that's precisely what I was pointing at.
> Will contain the text "on" if the connection is using SSL/TLS, or "off" otherwise.
> (This variable can be safely used regardless of whether or not mod_ssl is loaded).
>
> Now I just have to find out how I can actually access such a "server variable" inside a
> mod_perl handler. But that should be a breeze, considering the nice online mod_perl
> documentation, right ?
You don't need to. Just write something like :
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}?ssl=off
and parse the query string in your handler for the ssl parameter with
$req->param
> Let's see if I can beat Torsten to it..
>
>
>
--
Vincent Veyron
http://marica.fr/
Logiciel de gestion des assurances sinistres et des dossiers contentieux pour le service juridique
Re: get the incoming TCP protocol type
Posted by André Warnier <aw...@ice-sa.com>.
Vincent Veyron wrote:
> Le samedi 24 novembre 2012 à 16:58 +0100, André Warnier a écrit :
>
>> Is there somewhere a "is_secure()" or something which provides that ?
>> Or can I rely on the presence/absence of some request header ?
>>
>
>
> Apache's mod_rewrite has the HTTPS RewriteCond directive, which I use to
> enforce https access on a site like so:
>
> RewriteCond %{HTTPS} off
>
> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
>
> May be you can use this to mark the request somehow?
>
My problem is slightly different : I don't need to "enforce" HTTPS on the requests which I
proxy; I need to determine if the incoming request was made via HTTPS.
But your tip above actually pointed to something which may be of use to me : in
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
there is apparently a "server variable" HTTPS which can be tested in a RewriteCond, and
which looks just like what I need :
HTTPS
Will contain the text "on" if the connection is using SSL/TLS, or "off" otherwise.
(This variable can be safely used regardless of whether or not mod_ssl is loaded).
Now I just have to find out how I can actually access such a "server variable" inside a
mod_perl handler. But that should be a breeze, considering the nice online mod_perl
documentation, right ?
Let's see if I can beat Torsten to it..
Re: get the incoming TCP protocol type
Posted by Vincent Veyron <vv...@wanadoo.fr>.
Le samedi 24 novembre 2012 à 16:58 +0100, André Warnier a écrit :
> Is there somewhere a "is_secure()" or something which provides that ?
> Or can I rely on the presence/absence of some request header ?
>
Apache's mod_rewrite has the HTTPS RewriteCond directive, which I use to
enforce https access on a site like so:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
May be you can use this to mark the request somehow?
--
Vincent Veyron
http://marica.fr/
Logiciel de gestion des assurances sinistres et des dossiers contentieux pour le service juridique
Re: get the incoming TCP protocol type
Posted by Mark Eggers <it...@yahoo.com>.
On 11/24/2012 2:47 PM, André Warnier wrote:
> Ooops, sorry, wrong list. Please ignore.
>
> André Warnier wrote:
>> Torsten Förtsch wrote:
>>> On 11/24/2012 08:11 PM, Fred Moyer wrote:
>>>> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
> etc...
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
For apxs (it's in /usr/sbin/apxs in Fedora 17), try installing httpd-devel.
I don't know what the corresponding packages are on other distros.
I typically install:
apr-devel
apr-util-devel
httpd-devel
That keeps me out of (or in) trouble most of the time.
I hope this helps.
. . . just my turkified 2 cents
/mde/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: get the incoming TCP protocol type
Posted by André Warnier <aw...@ice-sa.com>.
Ooops, sorry, wrong list. Please ignore.
André Warnier wrote:
> Torsten Förtsch wrote:
>> On 11/24/2012 08:11 PM, Fred Moyer wrote:
>>> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
etc...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: get the incoming TCP protocol type
Posted by André Warnier <aw...@ice-sa.com>.
Torsten Förtsch wrote:
> On 11/24/2012 08:11 PM, Fred Moyer wrote:
>> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
>>>> Inside a mod_perl2 request handler, how can I find out if the current
>>>> request was received via HTTP or HTTPS ?
>> Torsten is the author of this module, so he can explain it in more
>> detail, but it looks like it can do part of what you need:
>>
>> https://metacpan.org/module/Apache2::ModSSL
>
> That is, of course, what I would use. If I recall correctly, the module
> was written to have access to the SSL related information *prior to* the
> response phase. If you need it only in the response phase you can have
> mod_ssl export almost all of the stuff accessible via Apache2::ModSSL as
> environment variables accessible via $r->subprocess_env.
>
I'm in the Fixup phase.
Hmm.
C:\develop\06_SVN\AP2lib\trunk\modlib\PROXY>ppm search Apache2::ModSSL
Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Downloading bribes-5.12 packlist...not modified
Downloading trouchelle-5.12 packlist...not modified
Downloading winnipeg-5.12 packlist...not modified
Downloading wxperl packlist...not modified
*** no packages matching 'Apache2::ModSSL' found ***
No Win32 port available for that, I guess.
We work mostly (whenever we can get away with it, essentially) on Linux servers, but try
to keep our solutions portable to Windows too, since we occasionally have clients that
insist on it.
However, the real target system this time is Linux, and it's kind of one-of-a-kind for
now, so let's try :
root@arthur:~# apt-cache search apache2 | grep SSL
libapache2-mod-log-sql-ssl - Use SQL to store/write your apache queries logs - SSL extension
libapache2-mod-gnutls - Apache module for SSL and TLS encryption with GnuTLS
Hmm. So, the hard way :
....
GOT /root/.cpan/sources/authors/id/O/OP/OPI/CHECKSUMS.tmp8430
Checksum for /root/.cpan/sources/authors/id/O/OP/OPI/Apache2-ModSSL-0.08.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.88)
Apache2-ModSSL-0.08/
Apache2-ModSSL-0.08/t/
Apache2-ModSSL-0.08/t/conf/
Apache2-ModSSL-0.08/t/conf/localhost.cert
Apache2-ModSSL-0.08/t/conf/extra.conf.in
Apache2-ModSSL-0.08/t/TestSSL/
Apache2-ModSSL-0.08/t/TestSSL/is_https.pm
Apache2-ModSSL-0.08/t/TestSSL/lookup.pm
Apache2-ModSSL-0.08/t/2lookup.t
Apache2-ModSSL-0.08/t/1is_https.t
Apache2-ModSSL-0.08/t/TEST.PL
Apache2-ModSSL-0.08/META.yml
Apache2-ModSSL-0.08/Changes
Apache2-ModSSL-0.08/perl-Apache2-ModSSL.spec
Apache2-ModSSL-0.08/MANIFEST
Apache2-ModSSL-0.08/Makefile.PL
Apache2-ModSSL-0.08/lib/
Apache2-ModSSL-0.08/lib/Apache2/
Apache2-ModSSL-0.08/lib/Apache2/ModSSL.pm
Apache2-ModSSL-0.08/README
Apache2-ModSSL-0.08/mk_README.sh
Apache2-ModSSL-0.08/ModSSL.xs
CPAN: File::Temp loaded ok (v0.22)
CPAN.pm: Going to build O/OP/OPI/Apache2-ModSSL-0.08.tar.gz
Could not figure out which apxs to use. Try the -apxs option.
Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
OPI/Apache2-ModSSL-0.08.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
root@arthur:~#
Ok, I'm a bit rusty about building from CPAN.
This is Linux Debian :
root@arthur:~# uname -a
Linux arthur 2.6.32-5-686 #1 SMP Mon Mar 26 05:20:33 UTC 2012 i686 GNU/Linux
Perl is :
root@arthur:~# perl -vv
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
(with 56 registered patches, see perl -V for more detail)
Apache httpd is :
[Mon Nov 12 15:01:23 2012] [notice] Apache/2.2.16 (Debian) DAV/2 SVN/1.6.12 mod_jk/1.2.30
PHP/5.3.3-7+squeeze8 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o
mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
But I do not find an "apxs" anywhere.
Do I need to install some "dev" package to get it ?
root@arthur:~# apt-cache search apache2 | grep dev
apache2-prefork-dev - Apache development headers - non-threaded MPM
apache2-threaded-dev - Apache development headers - threaded MPM
libapache2-mod-perl2-dev - Integration of perl with the Apache2 web server - development files
?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: get the incoming TCP protocol type
Posted by Fred Moyer <fr...@redhotpenguin.com>.
> But I do not find an "apxs" anywhere.
> Do I need to install some "dev" package to get it ?
The Debian executables can have non-standard names - try apxs2?
On Sat, Nov 24, 2012 at 2:51 PM, André Warnier <aw...@ice-sa.com> wrote:
> Torsten Förtsch wrote:
>>
>> On 11/24/2012 08:11 PM, Fred Moyer wrote:
>>>
>>> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
>>>>>
>>>>> Inside a mod_perl2 request handler, how can I find out if the current
>>>>> request was received via HTTP or HTTPS ?
>>>
>>> Torsten is the author of this module, so he can explain it in more
>>> detail, but it looks like it can do part of what you need:
>>>
>>> https://metacpan.org/module/Apache2::ModSSL
>>
>>
>> That is, of course, what I would use. If I recall correctly, the module
>> was written to have access to the SSL related information *prior to* the
>> response phase. If you need it only in the response phase you can have
>> mod_ssl export almost all of the stuff accessible via Apache2::ModSSL as
>> environment variables accessible via $r->subprocess_env.
>>
>
> I'm in the Fixup phase.
>
> Hmm.
> C:\develop\06_SVN\AP2lib\trunk\modlib\PROXY>ppm search Apache2::ModSSL
> Downloading ActiveState Package Repository packlist...done
> Updating ActiveState Package Repository database...done
> Downloading bribes-5.12 packlist...not modified
> Downloading trouchelle-5.12 packlist...not modified
> Downloading winnipeg-5.12 packlist...not modified
> Downloading wxperl packlist...not modified
> *** no packages matching 'Apache2::ModSSL' found ***
>
> No Win32 port available for that, I guess.
> (We work mostly (whenever we can get away with it, essentially) on Linux
> servers, but try
> to keep our solutions portable to Windows too, since we occasionally have
> clients that
> insist on it.)
>
> Building it on Windows from the tar.gz doesn't seem to work either, as it
> appears to require gcc (and probably a lot of other things not available on
> my XP laptop).
>
> However, the real target system this time is Linux, and it's kind of
> one-of-a-kind for
> now, so let's try :
>
> root@arthur:~# apt-cache search apache2 | grep SSL
> libapache2-mod-log-sql-ssl - Use SQL to store/write your apache queries logs
> - SSL extension
> libapache2-mod-gnutls - Apache module for SSL and TLS encryption with GnuTLS
>
> Hmm, no handy Debian package. So, the hard way :
>
> ....
> GOT /root/.cpan/sources/authors/id/O/OP/OPI/CHECKSUMS.tmp8430
> Checksum for
> /root/.cpan/sources/authors/id/O/OP/OPI/Apache2-ModSSL-0.08.tar.gz ok
> CPAN: Archive::Tar loaded ok (v1.88)
> Apache2-ModSSL-0.08/
> Apache2-ModSSL-0.08/t/
> Apache2-ModSSL-0.08/t/conf/
> Apache2-ModSSL-0.08/t/conf/localhost.cert
> Apache2-ModSSL-0.08/t/conf/extra.conf.in
> Apache2-ModSSL-0.08/t/TestSSL/
> Apache2-ModSSL-0.08/t/TestSSL/is_https.pm
> Apache2-ModSSL-0.08/t/TestSSL/lookup.pm
> Apache2-ModSSL-0.08/t/2lookup.t
> Apache2-ModSSL-0.08/t/1is_https.t
> Apache2-ModSSL-0.08/t/TEST.PL
> Apache2-ModSSL-0.08/META.yml
> Apache2-ModSSL-0.08/Changes
> Apache2-ModSSL-0.08/perl-Apache2-ModSSL.spec
> Apache2-ModSSL-0.08/MANIFEST
> Apache2-ModSSL-0.08/Makefile.PL
> Apache2-ModSSL-0.08/lib/
> Apache2-ModSSL-0.08/lib/Apache2/
> Apache2-ModSSL-0.08/lib/Apache2/ModSSL.pm
> Apache2-ModSSL-0.08/README
> Apache2-ModSSL-0.08/mk_README.sh
> Apache2-ModSSL-0.08/ModSSL.xs
> CPAN: File::Temp loaded ok (v0.22)
>
> CPAN.pm: Going to build O/OP/OPI/Apache2-ModSSL-0.08.tar.gz
>
> Could not figure out which apxs to use. Try the -apxs option.
> Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
> OPI/Apache2-ModSSL-0.08.tar.gz
> /usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
> Running make test
> Make had some problems, won't test
> Running make install
> Make had some problems, won't install
> root@arthur:~#
>
> Ok, I'm a bit rusty about building from CPAN.
>
> This is Linux Debian :
>
> root@arthur:~# uname -a
> Linux arthur 2.6.32-5-686 #1 SMP Mon Mar 26 05:20:33 UTC 2012 i686 GNU/Linux
>
> Perl is :
> root@arthur:~# perl -vv
>
> This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
> (with 56 registered patches, see perl -V for more detail)
>
> Apache httpd is :
> [Mon Nov 12 15:01:23 2012] [notice] Apache/2.2.16 (Debian) DAV/2 SVN/1.6.12
> mod_jk/1.2.30
> PHP/5.3.3-7+squeeze8 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o
> mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming
> normal operations
>
> But I do not find an "apxs" anywhere.
> Do I need to install some "dev" package to get it ?
>
> root@arthur:~# apt-cache search apache2 | grep dev
> apache2-prefork-dev - Apache development headers - non-threaded MPM
> apache2-threaded-dev - Apache development headers - threaded MPM
> libapache2-mod-perl2-dev - Integration of perl with the Apache2 web server -
> development files
>
> ?
>
>
>
Re: get the incoming TCP protocol type
Posted by Torsten Förtsch <to...@gmx.net>.
On 11/24/2012 11:51 PM, André Warnier wrote:
> Building it on Windows from the tar.gz doesn't seem to work either, as
> it appears to require gcc (and probably a lot of other things not
> available on my XP laptop).
ModSSL.xs does not contain any Linux-specific stuff. It should be
compilable on Windows, as well, provided you have the right environment
to compile apache modules.
> libapache2-mod-gnutls - Apache module for SSL and TLS encryption with
> GnuTLS
You know that mod_gnutls is something completely different from mod_ssl?
> CPAN.pm: Going to build O/OP/OPI/Apache2-ModSSL-0.08.tar.gz
>
> Could not figure out which apxs to use. Try the -apxs option.
This is the hint you need. When apache is compiled and installed the
apxs program is installed along with it. It is needed to find out about
installation locations and compile time options related to your apache
installation. It is normally looked up as "apxs" in your $PATH.
Apache2::ModSSL is an XS module. So, you need all the perl, modperl,
modssl, openssl and apache dev stuff there is.
Torsten
Re: get the incoming TCP protocol type
Posted by André Warnier <aw...@ice-sa.com>.
Torsten Förtsch wrote:
> On 11/24/2012 08:11 PM, Fred Moyer wrote:
>> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
>>>> Inside a mod_perl2 request handler, how can I find out if the current
>>>> request was received via HTTP or HTTPS ?
>> Torsten is the author of this module, so he can explain it in more
>> detail, but it looks like it can do part of what you need:
>>
>> https://metacpan.org/module/Apache2::ModSSL
>
> That is, of course, what I would use. If I recall correctly, the module
> was written to have access to the SSL related information *prior to* the
> response phase. If you need it only in the response phase you can have
> mod_ssl export almost all of the stuff accessible via Apache2::ModSSL as
> environment variables accessible via $r->subprocess_env.
>
I'm in the Fixup phase.
Hmm.
C:\develop\06_SVN\AP2lib\trunk\modlib\PROXY>ppm search Apache2::ModSSL
Downloading ActiveState Package Repository packlist...done
Updating ActiveState Package Repository database...done
Downloading bribes-5.12 packlist...not modified
Downloading trouchelle-5.12 packlist...not modified
Downloading winnipeg-5.12 packlist...not modified
Downloading wxperl packlist...not modified
*** no packages matching 'Apache2::ModSSL' found ***
No Win32 port available for that, I guess.
(We work mostly (whenever we can get away with it, essentially) on Linux servers, but try
to keep our solutions portable to Windows too, since we occasionally have clients that
insist on it.)
Building it on Windows from the tar.gz doesn't seem to work either, as it appears to
require gcc (and probably a lot of other things not available on my XP laptop).
However, the real target system this time is Linux, and it's kind of one-of-a-kind for
now, so let's try :
root@arthur:~# apt-cache search apache2 | grep SSL
libapache2-mod-log-sql-ssl - Use SQL to store/write your apache queries logs - SSL extension
libapache2-mod-gnutls - Apache module for SSL and TLS encryption with GnuTLS
Hmm, no handy Debian package. So, the hard way :
....
GOT /root/.cpan/sources/authors/id/O/OP/OPI/CHECKSUMS.tmp8430
Checksum for /root/.cpan/sources/authors/id/O/OP/OPI/Apache2-ModSSL-0.08.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.88)
Apache2-ModSSL-0.08/
Apache2-ModSSL-0.08/t/
Apache2-ModSSL-0.08/t/conf/
Apache2-ModSSL-0.08/t/conf/localhost.cert
Apache2-ModSSL-0.08/t/conf/extra.conf.in
Apache2-ModSSL-0.08/t/TestSSL/
Apache2-ModSSL-0.08/t/TestSSL/is_https.pm
Apache2-ModSSL-0.08/t/TestSSL/lookup.pm
Apache2-ModSSL-0.08/t/2lookup.t
Apache2-ModSSL-0.08/t/1is_https.t
Apache2-ModSSL-0.08/t/TEST.PL
Apache2-ModSSL-0.08/META.yml
Apache2-ModSSL-0.08/Changes
Apache2-ModSSL-0.08/perl-Apache2-ModSSL.spec
Apache2-ModSSL-0.08/MANIFEST
Apache2-ModSSL-0.08/Makefile.PL
Apache2-ModSSL-0.08/lib/
Apache2-ModSSL-0.08/lib/Apache2/
Apache2-ModSSL-0.08/lib/Apache2/ModSSL.pm
Apache2-ModSSL-0.08/README
Apache2-ModSSL-0.08/mk_README.sh
Apache2-ModSSL-0.08/ModSSL.xs
CPAN: File::Temp loaded ok (v0.22)
CPAN.pm: Going to build O/OP/OPI/Apache2-ModSSL-0.08.tar.gz
Could not figure out which apxs to use. Try the -apxs option.
Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
OPI/Apache2-ModSSL-0.08.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
root@arthur:~#
Ok, I'm a bit rusty about building from CPAN.
This is Linux Debian :
root@arthur:~# uname -a
Linux arthur 2.6.32-5-686 #1 SMP Mon Mar 26 05:20:33 UTC 2012 i686 GNU/Linux
Perl is :
root@arthur:~# perl -vv
This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi
(with 56 registered patches, see perl -V for more detail)
Apache httpd is :
[Mon Nov 12 15:01:23 2012] [notice] Apache/2.2.16 (Debian) DAV/2 SVN/1.6.12 mod_jk/1.2.30
PHP/5.3.3-7+squeeze8 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o
mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations
But I do not find an "apxs" anywhere.
Do I need to install some "dev" package to get it ?
root@arthur:~# apt-cache search apache2 | grep dev
apache2-prefork-dev - Apache development headers - non-threaded MPM
apache2-threaded-dev - Apache development headers - threaded MPM
libapache2-mod-perl2-dev - Integration of perl with the Apache2 web server - development files
?
Re: get the incoming TCP protocol type
Posted by Torsten Förtsch <to...@gmx.net>.
On 11/24/2012 08:11 PM, Fred Moyer wrote:
> On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
>> > Inside a mod_perl2 request handler, how can I find out if the current
>> > request was received via HTTP or HTTPS ?
> Torsten is the author of this module, so he can explain it in more
> detail, but it looks like it can do part of what you need:
>
> https://metacpan.org/module/Apache2::ModSSL
That is, of course, what I would use. If I recall correctly, the module
was written to have access to the SSL related information *prior to* the
response phase. If you need it only in the response phase you can have
mod_ssl export almost all of the stuff accessible via Apache2::ModSSL as
environment variables accessible via $r->subprocess_env.
Torsten
Re: get the incoming TCP protocol type
Posted by Fred Moyer <fr...@redhotpenguin.com>.
On Sat, Nov 24, 2012 at 7:58 AM, André Warnier <aw...@ice-sa.com> wrote:
> Inside a mod_perl2 request handler, how can I find out if the current
> request was received via HTTP or HTTPS ?
Torsten is the author of this module, so he can explain it in more
detail, but it looks like it can do part of what you need:
https://metacpan.org/module/Apache2::ModSSL
use Apache2::ModSSL;
my $c=$r->connection;
if( $c->is_https )
>
> I mean :
> The client (browser e.g.) gets a URL "http://host.x.y/path1/path2..", and
> - translates host.x.y to an IP
> - makes a connection to that IP (and port)
> - sends a request like :
> GET /path1/path2.. HTTP/1.1
> Host: host.x.y
> ...
>
> OR
> The client (browser e.g.) gets a URL "https://host.x.y/path1/path2..", and
> - translates host.x.y to an IP
> - makes an *SSL* connection to that IP (and port)
> - sends a request like :
> GET /path1/path2.. HTTP/1.1
> Host: host.x.y
> ...
>
> and
>
> Inside a handler, I can get
> $r->hostname ==> host.x.y
> $r->uri and $r->unparsed_uri ==> /path1/path2..
>
> and I can also get the port on which the request was received (presumably),
> via
> $r->get_server_port
> but that is not really a guarantee, any port could be set for either HTTP or
> HTTPS.
>
> and then I see
> $r->proto and $r->proto_num
> but these are relative to the protocol string as it appears in the first
> request line, not to the type of connection that was used for the request.
> And in the request, I guess it would always be HTTP/1.1, or ?
> (I don't have a HTTPS host right now to check this)
>
> And I haven't really found anything yet in Apache2:RequestRec,
> Apache2::Connection or Apache2::ServerRec which would provide that
> information.
>
> Is there somewhere a "is_secure()" or something which provides that ?
> Or can I rely on the presence/absence of some request header ?
>
> Help..
>
>
> The point is, I'd like to write the handler once, and use it inside a HTTP
> or a HTTPS host indifferently. And if possible, I'd also like to avoid
> having to tell the handler where he lives via some PerlSetVar just for that.
> But maybe that's the easiest solution ?
>