最近在做的是web server从apache到nginx的转换,
主要的工作就是日志格式还有rewrite以及虚拟主机的转换。
以下是我查阅到的比较有用的配置资料和一些总结:
1、apache的LogFormat选项(配置参数/内置变量):
(来自:http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats)
The characteristics of the request itself are logged by placing "%
" directives in the format string, which are replaced in the log file by the values as follows:
%% |
The percent sign |
%a |
Remote IP-address |
%A |
Local IP-address |
%B |
Size of response in bytes, excluding HTTP headers. |
%b |
Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '- ' rather than a 0 when no bytes are sent. |
%{Foobar}C |
The contents of cookie Foobar in the request sent to the server. Only version 0 cookies are fully supported. |
%D |
The time taken to serve the request, in microseconds. |
%{FOOBAR}e |
The contents of the environment variable FOOBAR
|
%f |
Filename |
%h |
Remote host |
%H |
The request protocol |
%{Foobar}i |
The contents of Foobar: header line(s) in the request sent to the server. Changes made by other modules (e.g. mod_headers ) affect this. If you're interested in what the request header was prior to when most modules would have modified it, use mod_setenvif to copy the header into an internal environment variable and log that value with the %{VARNAME}e described above. |
%k |
Number of keepalive requests handled on this connection. Interesting if KeepAlive is being used, so that, for example, a '1' means the first keepalive request after the initial one, '2' the second, etc...; otherwise this is always 0 (indicating the initial request). Available in versions 2.2.11 and later. |
%l |
Remote logname (from identd, if supplied). This will return a dash unless mod_ident is present and IdentityCheck is set On . |
%m |
The request method |
%{Foobar}n |
The contents of note Foobar from another module. |
%{Foobar}o |
The contents of Foobar: header line(s) in the reply. |
%p |
The canonical port of the server serving the request |
%{format}p |
The canonical port of the server serving the request or the server's actual port or the client's actual port. Valid formats are canonical , local , orremote . |
%P |
The process ID of the child that serviced the request. |
%{format}P |
The process ID or thread id of the child that serviced the request. Valid formats are pid , tid , and hextid . hextid requires APR 1.2.0 or higher. |
%q |
The query string (prepended with a ? if a query string exists, otherwise an empty string) |
%r |
First line of request |
%R |
The handler generating the response (if any). |
%s |
Status. For requests that got internally redirected, this is the status of the *original* request --- %>s for the last. |
%t |
Time the request was received (standard english format) |
%{format}t |
The time, in the form given by format, which should be in strftime(3) format. (potentially localized) |
%T |
The time taken to serve the request, in seconds. |
%u |
Remote user (from auth; may be bogus if return status (%s ) is 401) |
%U |
The URL path requested, not including any query string. |
%v |
The canonical ServerName of the server serving the request. |
%V |
The server name according to the UseCanonicalName setting. |
%X |
Connection status when response is completed:
X = |
connection aborted before the response completed. |
+ = |
connection may be kept alive after the response is sent. |
- = |
connection will be closed after the response is sent. |
(This directive was %c in late versions of Apache 1.3, but this conflicted with the historical ssl %{var}c syntax.)
|
%I |
Bytes received, including request and headers, cannot be zero. You need to enable mod_logio to use this. |
%O |
Bytes sent, including headers, cannot be zero. You need to enable mod_logio to use this. |
2、nginx的log_format配置参数(内置变量):
(来自:http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format)
The log format can contain common variables, and variables that exist only at the time of a log write:
$body_bytes_sent
the number of bytes sent to a client not counting the response header; this variable is compatible with the “%B
” parameter of the mod_log_config
Apache module
$bytes_sent
the number of bytes sent to a client
$connection
connection serial number
$connection_requests (nginx 1.1.18版本及以后版本才有这个变量)
the current number of requests made through a connection
$msec
time in seconds with a milliseconds resolution at the time of log write
$pipe
“p
” if request was pipelined, “.
” otherwise
$request_length
request length (including request line, header, and request body)
$request_time
request processing time in seconds with a milliseconds resolution; time elapsed between the first bytes were read from the client and the log write after the last bytes were sent to the client
$status
response status
$time_iso8601
local time in the ISO 8601 standard format
$time_local
local time in the Common Log Format
Header lines sent to a client have the prefix “sent_http_
”,
for example, $sent_http_content_range
.
The configuration always includes the predefined format “combined
”:
log_format combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
分享到:
相关推荐
一个开源的Linux下运行... 该工具从Apache Web服务器中的各模块功能的角度进行分析,生成Nginx中相应模块的配置方式,然后以报告的形式生成转换后的Nginx配置文件。 官网:https://github.com/leeleander/apache2nginx
Apache + nginx + resin 详细配置
Apache2Nginx是一个开源的linux下运行的...它可以把apache 配置文件转换成对应的nginx 配置文件.对于一般的功能. 比如目录 url重写.这都从测试来看.基本上不存在问题.对于不能转换的.会有注释在转换好的配置文件中体现.
linux + apache(nginx) + mysql + php 配置 详解
快速简简单的搭建一个http服务器,提供http服务,对http服务器要求不高; apache简单配置 nginx简单配置
cluster+apache+nginx整合集群配置
一个开源的Linux下运行的命令行工具,能将Apache的配置文件转换成相应的... 该工具从Apache Web服务器中的各模块功能的角度进行分析,生成Nginx中相应模块的配置方式,然后以报告的形式生成转换后的Nginx配置文件。
Nginx超过Apache10倍的配置方法, 金山网络内部人士分享
1.4. Nginx和Apache的区别 2. 安装Nginx服务器 2.1. 在windows上安装 2.2. 在Linux上安装 2.2.1. 写在前面 2.2.2. 准备使用yum安装nginx的运行环境 2.2.3. 安装pcre 2.2.4. 安装zlib库 2.2.5. 安装nginx ...
Apache2Nginx 一个命令行工具,可用于根据Apache的给定配置文件生成nginx配置文件。概述NGINX(“engine x”)是一个高性能的 Web 服务器、缓存代理和第 7 层负载平衡解决方案。 互联网上数以百万计的网站受益于使用...
1)编辑yum配置文件: 2)剪切/etc/yum.repos.d/CentOS-Base.repo 3)依次安装gcc、gcc-c++ 2、关闭系统RPM安装包的Apache、MySQL的服务 3、关闭SELinux,允许防火墙80端口访问 1)关闭SELinux 2)关闭防火墙...
实战Nginx_取代Apache的高性能Web服务器_第5章_Nginx与JSP、ASP.NET、Perl的安装与配置
配置Nginx前端Apache后端服务器,负载均衡等
freeBSD配置php mysql apache nginx,里面有详细的说明,一步步告诉大家怎样配置。freeBSD配置php mysql apache nginx,里面有详细的说明,一步步告诉大家怎样配置。
prestashop_1.6.0.9 从apache转换nginx服务器的重写规则 text.conf是apache的.htaccess转换成nginx的重写规则 将text.conf这个文件放在...然后在nginx的配置文件中include进来就可以了. 有什么问题欢迎指出,谢谢!~
搭建一个网站传统的方法是使用一个web服务器去解析文件入口文件,如使用Nginx,Apache解析到对应的入口文件,但是随着技术的发展,一些语言可以自己起一个web服务,如Node,PHP,使用开发语言启动一个web服务默认只能在...
1、全面适合 Win2000/XP/2003/win7/win8/win2008 操作系统 ,支持Apache、IIS、Nginx和LightTPD。 2、该程序包集成以下软件,括号内为phpstudy下对应的目录。 php 7.0.12 php 5.6.27 php 5.5.38 php 5.4.35...
Nginx选择了epoll和kqueue作为网络I/O模型,在高连接并发的情况下,Nginx是Apache服务器不错的替代品,它能够支持高达50 000个并发连接数的响应,运行稳定,且内存、CPU等系统资源消耗非常低。, 本书主要分为4个部分...
keepalived配置haproxy,apache2,nginx,监听配置
5.nginx配置虚拟主机 6.nginx location配置 7.nginx root&alias文件路径配置 8.nginx日志配置 9.apache和nginx支持SSL配置 10.nginx日子切割 11.Nginx重新规则指南 12.Nginx逻辑运算 13.隐藏Nginx版本号的安全性与...