|
Previous
·
Next
|
bernd
|
Date: 7/6/2008 3:50 am · Subject: IPs of interfaces apache binds to · Rating: 0
How can I query IPs of interfaces apache binds to? I need this to distinguish between internal and external requests in the userSession table.
Bernd
-- Trying to build a non-profit community portal for free-climbers around Magdeburg/Germany. Check out http://www.klettern-md.de (under construction).
|
| Back to Top |
Rate [ | ]
|
| |
knowmad
|
Date: 7/6/2008 8:59 pm · Subject: Re: IPs of interfaces apache binds to · Rating: 2
How can I query IPs of interfaces apache binds to? I need this to distinguish between internal and external requests in the userSession table.
Hi Bernd,
Can you explain more about what you're trying to do? Are you trying to find this info from a macro? a custom wobject? Generally, you can query the referer string to find where the request is coming from. For mod_perl, try $r->headers_in('Referer') (see perl.apache.org for more, code not tested).
I'm not sure how you're going to know if the request is internal or external without some kind of lookup table or a regex (depending on how big your internal network is).
William
---- Knowmad Technologies http://www.knowmad.com
|
| Back to Top |
Rate [ | ]
|
| |
bernd
|
Date: 7/7/2008 2:42 pm · Subject: Re: IPs of interfaces apache binds to · Rating: 0
Hi Bernd,
Can you explain more about what you're trying to do? Are you trying to find this info from a macro? a custom wobject?
Hi William,
I am trying to improve the UsersOnline macro. In one place, the number of visitors is determined by the following query:
SELECT COUNT(DISTINCT lastIp) FROM userSession where (lastPageView >= $epoch) and (userId = 1)
However, I noticed that the number of visitors is increased artificially by internal requests. I assume this is due to mod_proxy accessing mod_perl or maybe due to spectre. Anyway, I would like to filter out ips belonging to the loopback device and ips apache binds to. That should solve the problem. Any idea?
Bernd
-- Trying to build a non-profit community portal for free-climbers around Magdeburg/Germany. Check out http://www.klettern-md.de (under construction).
|
| Back to Top |
Rate [ | ]
|
| |
JT
|
Date: 7/7/2008 7:35 pm · Subject: Re: IPs of interfaces apache binds to · Rating: 1
Are you saying that you don't already know what your internal IP
ranges are?
$session->server gives you a reference to Apache2::ServerUtil, which
can probably give you those IPs.
> How can I query IPs of interfaces apache binds to? I need this to
> distinguish between internal and external requests in the
> userSession table.
>
JT Smith
ph: 703-286-2525 x810
fx: 312-264-5382
Create like a god. Command like a king. Work like a slave.
|
| Back to Top |
Rate [ | ]
|
| |
dionak
|
Date: 7/7/2008 8:30 pm · Subject: Re: IPs of interfaces apache binds to · Rating: 1
To add to JT's comment, you could probably filter request by using a
regex on the IP, filtering out your interal IP's.
dionak
On Mon, Jul 7, 2008 at 8:36 PM, wrote:
> JT wrote:
>
> Are you saying that you don't already know what your internal IP
> ranges are?
>
> $session->server gives you a reference to Apache2::ServerUtil, which
> can probably give you those IPs.
>
>> How can I query IPs of interfaces apache binds to? I need this to
>> distinguish between internal and external requests in the
>> userSession table.
>>
>
>
>
>
> JT Smith
> ph: 703-286-2525 x810
> fx: 312-264-5382
>
> Create like a god. Command like a king. Work like a slave.
>
>
>
> http://www.plainblack.com/webgui/dev/discuss/ips-of-interfaces-apache-binds-to/3
>
>
> --
>
>
>
> Plain Black, makers of WebGUI
>
> http://plainblack.com
>
>
>
--
Knowmad Technologies - Open Source Software Solutions
W: http://www.knowmad.com | E: diona@knowmad.com
P: 704.343.9330 | http://www.LinkedIn.com/in/dionakidd
|
| Back to Top |
Rate [ | ]
|
| |
apeiron
|
Date: 7/8/2008 10:35 am · Subject: Re: IPs of interfaces apache binds to · Rating: 1
On Jul 7, 2008, at 20:30 :35,
wrote:
> dionak wrote:
>
> To add to JT's comment, you could probably filter request by using a
> regex on the IP, filtering out your interal IP's.
I would probably go with http://search.cpan.org/~frajulac/Net-IPv4Addr-0.10/IPv4Addr.pm
to keep things simple and maintainable. Yes, it's an encapsulation
of some regexes (although it uses unpack in several places), but it's
a *readable* encapsulation. :)
Chris Nehren // Plain Black
p 1.703.286.2525 x 811
m 1.267.573.1000
f 1.312.264.5382
|
| Back to Top |
Rate [ | ]
|
| |
bernd
|
Date: 7/27/2008 6:46 am · Subject: Re: IPs of interfaces apache binds to · Rating: 0
Are you saying that you don't already know what your internal IP ranges are?
$session->server gives you a reference to Apache2::ServerUtil, which can probably give you those IPs.
$session->server returns an object of type Apache2::ServerRec, in fact. The documentation of this field is incorrect and should be updated
If someone was interested, the following code is what I had been looking for:
# Query server hostname my $hostname = $session->server->server_hostname();
# Look up server IP addresses my $ip_clause; my $res = Net::DNS::Resolver->new(); my $query = $res->search($hostname); if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "A"; # Generate SQL clause which excludes server IPs $ip_clause = $ip_clause . " AND STRCMP(lastIp, '" . $rr->address . "')"; } }
$ip_clause can now be added to SQL queries in order to filter out server ips.
|
| Back to Top |
Rate [ | ]
|
| |
|
|
Recent Discussions Color Key |
| Design: |
|
| Development: |
|
| Et Cetera: |
|
| Install/Upgrade: |
|
| Smoketest: |
|
| Template Group: |
|
Re: Site paid for by advertizing by Klaus - Fri @ 02:27am Re: Site paid for by advertizing by pwrightson - Thu @ 10:59am Re: Site paid for by advertizing by JT - Thu @ 08:58am Re: Regelmäßiger Termin für Usertreffen in der Rhein-Neckar-Region by Klaus - Thu @ 06:11am Re: Site paid for by advertizing by knowmad - Wed @ 08:07pm
|