logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache 2.4, SetEnvIf problems with logging.
Author
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 21 Jul '12 10:53    Post subject: Apache 2.4, SetEnvIf problems with logging. Reply with quote

Hi.

I have been trying and trying to make apache 2.2 & 2.4 on Windows_x64 sp1+ with PHP 5.4 not to log local IP actions with (mod_setenvif)

Code:
SetEnvIf Remote_Addr "192\.168\.0\.*" dontlog

and
Code:
CustomLog combined env=!dontlog


but in vain, I just keep getting access log entries.. what gives! I'm Using SSL redirectEngine..

Is there some special place where to put this SetEnvIf that is apply?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Sat 21 Jul '12 11:14    Post subject: Reply with quote

An example, how I do it:

CustomLog f:/log/apache/access.log combined env=!no

SetEnvIf Remote_Addr "127\.0\.0\.1" no
SetEnvIf Remote_Addr "192\.168\.0\.1" no
SetEnvIf Request_URI "\.gif$" no
SetEnvIf Request_URI "\.js$" no
SetEnvIf Request_URI "\.jpg$" no

What is a SSL redirectEngine ?
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 21 Jul '12 11:20    Post subject: Reply with quote

Believe me, I have tried all of those, no efect: apache just keeps logging the IP events, i have tried to disclude.

1. Where do you put the SetEnvIF clause? Inside <Directory ?
2. What modules are needed (i have read the API reference of SetEnv).


SSL redirect to me is

Code:
Require all granted
    RewriteEngine On
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Sat 21 Jul '12 11:25    Post subject: Reply with quote

I believe you Smile

I have it in the main conf, not within a <Directory.
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 21 Jul '12 11:27    Post subject: Reply with quote

can you give me spcific place where you have the SetEnvIf and what modules do you have on.

There has to be something different with
Remote_Addr "127\.0\.0\.1" clause whenn running on Windows 7..
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Sat 21 Jul '12 11:45    Post subject: Reply with quote

In the main conf as I said.

...
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule xml2enc_module modules/mod_xml2enc.so
...
here
...

When Apache is not starting then you do not have the needed modules, so if your Apache is running then all needed modules are loaded.

No diff when running Win7
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 21 Jul '12 12:26    Post subject: Reply with quote

no, Not working like I want it to. It's still logging xxx.5 even with
Code:
SetEnvIf Remote_Addr "192\.168\.0\.5" no


Apache has been restarted everytime after config alter.. This is frustrating..
Mod is active
Code:
LoadModule setenvif_module modules/mod_setenvif.so

I have
Code:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/apac/root"
AccessFileName .htaccess


SetEnvIf Remote_Addr "127\.0\.0\.1" no
SetEnvIf Remote_Addr "192\.168\.0\.5" no
SetEnvIf Remote_Addr "192\.168\.0\.3" no

<Directory "c:/apac/root">...


and in the
Code:
<IfModule log_config_module>
..CustomLog "logs/access.log" combined  env=!no
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Sat 21 Jul '12 13:07    Post subject: Reply with quote

Do you see in your log like ?

xxxxx 192.168.0.5 - - [21/Jul/2012:07:17:00 +0200] "GET.....


Should work, maybe someone else can give advise.
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 21 Jul '12 15:36    Post subject: Reply with quote

The logfile states
Code:
192.168.0.5 - - [21/Jul/2012:13:23:24 +0300] "GET /
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Wed 25 Jul '12 6:23    Post subject: Reply with quote

Can anyone provide any suggestion Why SetEnvIf does not work? How Debug-mode can be turned on?
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Wed 25 Jul '12 8:42    Post subject: Reply with quote

Seems odd, I have this in 2.4 and it works

SetEnvIf Remote_Addr "192.168.0.1" LOCALNET=Yes
SetEnvIf Remote_Host "comp3" LOCALNET=Yes
SetEnvIf Remote_Host "comp7" LOCALNET=Yes
SetEnvIf Remote_Host "comp8" LOCALNET=Yes

CustomLog "logs/access.log" combined env=!LOCALNET


Curious, is mod_setenvif loaded? If not, it's not setting the envvar. You could also see if the envvar is being set looking at phpinfo() or some similar thing in whatever language.
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Wed 25 Jul '12 18:04    Post subject: Reply with quote

Ok, Thank you All Very much for helping me.
I have found the problem.

Above SetEnvIf works, IF I take redirecting to https off. That breaks the functionality!
Code:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


Without this redirecting to use SSL always, logging disclude works great.

http://turboflash.wordpress.com/2010/05/27/apache-environment-variables-visibility-with-setenv-setenvif-and-rewriterule-directives/
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Thu 09 Aug '12 20:57    Post subject: Reply with quote

Any suggestion on how to fix this?
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 09 Aug '12 23:52    Post subject: Reply with quote

is there a CustomLog directive in your ssl config? If there is it needs to have env=!no tacked onto the end of it also.
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Fri 10 Aug '12 9:06    Post subject: Reply with quote

Do you mean in the "httpd-ssl.conf" file under extras?
At the end of the file there is CustomLog for ssl_request.log file that is not the basic log as access.log

There is also "TransferLog" line in the config but that points just the access.log file.

SSLOptions +StdEnvVars points to cgi-bin folder.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Sat 11 Aug '12 1:57    Post subject: Reply with quote

Yes, that was what I meant so ok it's not that
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 25 Aug '12 20:53    Post subject: Reply with quote

Well... No solution?
Back to top
Jurmalauge



Joined: 19 Jul 2012
Posts: 11
Location: finland, helsinki

PostPosted: Sat 08 Sep '12 11:14    Post subject: Reply with quote

I had to switch the SSL redirect off in order to make this disclude operation to work.. not good!
Back to top


Reply to topic   Topic: Apache 2.4, SetEnvIf problems with logging. View previous topic :: View next topic
Post new topic   Forum Index -> Apache