Linux notes: apache configuration and logs

Source: Internet
Author: User
Linux notes: apache configuration and log-Linux Enterprise Application-Linux server application information. For details, refer to the following section. Alibaba Cloud handled apache configuration today:
1. Set Environment Variables
2. Handling leeching Methods
3. Separate and save logs

1. Set Environment Variables

In apache, you can use regular expressions to determine many variables, and then set another variable for later configuration.
For example, you need to determine whether the user accesses a folder and set a variable record:
SetEnvIfNoCase Request_URI "^ \/aslibra" ISSTART = 1

SetEnvIfNoCase is case-insensitive.
Request_URI matches "^ \/aslibra"
If yes, ISSTART = 1, otherwise it is not 1

In addition, for logs that do not record images, you can find the file path and set the variables for later use:

SetEnv NOFILES 1


CustomLog logs/access_log combined env =! NOFILES

2. Handling leeching

The referrer method is used to determine whether to process leeching. See the following example:

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 to determine that 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 to determine the source, and then do not allow this domain name

3. Log Segmentation

You can use cronolog to process log segmentation.
Installation is easier.

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 preceding defines the log format. You can define many log formats for subsequent log usage.
For example, if you want to collect cookies (% {cookiename} C) and custom time formats (% {% T} t ), you can use the record-like method above.

CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/www.aslibra.com. % m % d % H" record
CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/aslibra.com. % m % d % H" combined

In the preceding example, cronolog is called to store logs. The following parameters are custom log formats.
Of course, you can also customize logs that record many conditions. For example, you only need to record the requests starting with/aslibra:

SetEnvIfNoCase Request_URI "^ \/aslibra" ISSTART = 1
CustomLog "|/Data/apps/cronolog/sbin/cronolog/Data/weblog/% Y/% m/% d/aslibra.com. % m % d % H" record env = ISSTART

Several mmlogs can be recorded together, and so on.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.