Linux server application: About Apache configuration and logging

  
                  

1, set the environment variable

In apache, you can use regular to judge a lot of variables, and then set another variable for later configuration use

For example, you have to determine whether the user is Access a folder and set a variable to record it:

SetEnvIfNoCase Request_URI "^\\/aslibra" ISSTART=1


SetEnvIfNoCase means case insensitive

Request_URI matches "^\\/aslibra"

If yes, ISSTART=1, otherwise it is not 1


In addition, no record The log of the image can be to find the file path, and then set the variable for later use:


SetEnv NOFILES 1


CustomLog logs/access_log combined Env=!NOFILES


2. Handling stolen chains


Handling stolen chains is generally done on the referrer, see the following example: Br>


SetEnvIfNoCase Referer "^http://www\\.aslibra\\.com/" local_ref=1


Order Allow, Deny

Allow from env=local_ref

Allow from 127.0.0.1


The above is the judgment The source is the above domain name, and then set to allow access


SetEnvIfNoCase Referer "^http://notpermit\\.aslibra\\.com/" aaa


Order Allow, Deny

Allow from all

Deny from env=aaa


The above is the source of the judgment, and then the domain name is not allowed< Br>


3, log splitting


Log splitting can be handled using cronolog

It is easier to install, just like normal software Installation


Definition format:


LogFormat "%h %l %u %t \\"%r\\" %>s %b \\"%{Referer}i\\" \\"%{User-Agent}i\\"" combined

LogFormat "%h %l %u %t \\"%r\\" %>s %b " common

LogFormat "%{Referer}i -> %U" referer

LogFormat "%{User-agent}i" agent


LogFormat "%h %{%T}t \\"%r\\" %{cookiename}C" record


The above is the definition of the log format, you can define a lot of log formats so that The following log is used

, for example, the common is combined, there is generally collected content, if you want to collect cookies (% {cookiename} C) and custom Inter-format (%{%T}t), you can use the above similar record method


CustomLog "

Copyright © Windows knowledge All Rights Reserved