본문 바로가기

Server/Apache

[Apache] Apache Http Header customizing(mod_headers)

<업무 복습>


- Default Response header에서 Request, Response 처리 시간을 추가하기 위해서 사용

============================================================================================


Apache Module mod_headers


Summary

This module provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed.


Order of Processing

The directives provided by mod_headers can occur almost anywhere within the server configuration, and can be limited in scope by enclosing them in configuration sections.

- 나는 전역설정이 아니라, 특정 포트에 적용하기 위해서 <Virtualhost> </Virtualhost> 안에 사용


Header set MyHeader "%D %t"

results in this header being added to the response:

MyHeader: D=3775428 t=991424704447256



Header Directive

Description:Configure HTTP response headers
Syntax:Header [condition] add|append|echo|edit|edit*|merge|set|setifempty|unset|note header [[expr=]value[replacement] [early|env=[!]varname|expr=expression]]
Context:server config, virtual host, directory, .htaccess
Override:FileInfo
Status:Extension
Module:mod_headers
Compatibility:SetIfEmpty available in 2.4.7 and later, expr=value available in 2.4.10 and later

This directive can replace, merge or remove HTTP response headers. 



The action it performs is determined by the first argument (second argument if a condition is specified). This can be one of the following values:

add
The response header is added to the existing set of headers, even if this header already exists. This can result in two (or more) headers having the same name. This can lead to unforeseen consequences, and in general set, append or merge should be used instead.

- 업무 떄는 add를 사용했지만, 예상치 못한 오류를 범할 수 있기 떄문에 set, append를 추천하는구나... add보다는 저방법으로 사용하자(
append
The response header is appended to any existing header of the same name. When a new value is merged onto an existing header it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values.
set
The response header is set, replacing any previous header with this name. The value may be a format string.



FormatDescription
%%The percent sign
%tThe time the request was received in Universal Coordinated Time since the epoch (Jan. 1, 1970) measured in microseconds. The value is preceded by t=.
%DThe time from when the request was received to the time the headers are sent on the wire. This is a measure of the duration of the request. The value is preceded by D=. The value is measured in microseconds.
%lThe current load averages of the actual server itself. It is designed to expose the values obtained by getloadavg() and this represents the current load average, the 5 minute average, and the 15 minute average. The value is preceded by l= with each average separated by /.
Available in 2.4.4 and later.
%iThe current idle percentage of httpd (0 to 100) based on available processes and threads. The value is preceded by i=.
Available in 2.4.4 and later.
%bThe current busy percentage of httpd (0 to 100) based on available processes and threads. The value is preceded by b=.
Available in 2.4.4 and later.
%{VARNAME}eThe contents of the environment variable VARNAME.
%{VARNAME}sThe contents of the SSL environment variable VARNAME, if mod_ssl is enabled.




원문: 


https://httpd.apache.org/docs/current/en/mod/mod_headers.html