`
nigelzeng
  • 浏览: 606538 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

apache和nginx的一些配置资料

阅读更多

 

最近在做的是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:

Format String Description
%% 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 canonicallocal, 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 pidtid, and hextidhextid 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"';

 

分享到:
评论

相关推荐

    apache到nginx配置文件转换工具

    一个开源的Linux下运行... 该工具从Apache Web服务器中的各模块功能的角度进行分析,生成Nginx中相应模块的配置方式,然后以报告的形式生成转换后的Nginx配置文件。 官网:https://github.com/leeleander/apache2nginx

    Apache + nginx + resin 详细配置

    3. Nginx配置:Nginx作为反向代理服务器,它接收来自外部的请求,并将这些请求转发到Apache和Resin。在Nginx的`sites`配置文件中,创建一个名为`test.zen.com`的server块,设置server_name、access_log、gzip、...

    apache与nginx区别

    综上所述,Apache和Nginx各自有其独特的优势和适用场景。Apache在功能丰富性方面表现突出,适合处理复杂应用逻辑;而Nginx则因其高效、稳定的特点,在处理高并发请求方面更胜一筹。具体选择哪种服务器取决于项目需求...

    apache与nginx安装使用

    一个基本的Nginx配置示例,用于代理到本地运行的Node.js应用: ``` server { listen 80; server_name example.com; location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_...

    linux + apache(nginx) + mysql + php 配置 详解

    在Nginx配置中设置正确的location指令。 **优化与安全**: 1. 优化配置:例如,调整Apache或Nginx的worker进程数量,优化MySQL缓存设置。 2. 安全:安装防火墙如ufw,限制不必要的端口访问,定期更新系统和软件,...

    Apache2Nginx简单试用

    Apache2Nginx是一个开源的linux下运行的...它可以把apache 配置文件转换成对应的nginx 配置文件.对于一般的功能. 比如目录 url重写.这都从测试来看.基本上不存在问题.对于不能转换的.会有注释在转换好的配置文件中体现.

    cluster+apache+nginx

    文件名"cluster+apache2.2+nginx0.8"暗示了这可能是一个关于Apache 2.2版本和Nginx 0.8版本的集群配置示例。在这个配置中,用户可能会学习到如何安装这两个软件,配置Nginx的反向代理规则,以及如何在Apache上设置...

    apache配置文件转换到nginx配置文件的工具

    一个开源的Linux下运行的命令行工具,能将Apache的配置文件转换成相应的... 该工具从Apache Web服务器中的各模块功能的角度进行分析,生成Nginx中相应模块的配置方式,然后以报告的形式生成转换后的Nginx配置文件。

    配置Nginx前端Apache后端服务器

    虽然Nginx已承担了大部分日志记录和性能优化工作,但在某些情况下,可能仍需要在Apache上做一些配置。尤其是启用mod_rpaf模块,以正确识别并记录来自Nginx的真实客户端IP地址。 #### 实现负载均衡 在多台服务器...

    apache+nginx+tomcat

    - 配置文件同步:确保 Apache、Nginx 和 Tomcat 的配置文件同步,避免冲突。 - 日志管理:合理设置日志文件,便于监控和调试。 - 安全性:使用防火墙、安全组限制不必要的访问,定期更新软件,防止安全漏洞。 总的...

    apache2nginx.zip

    Apache2Nginx(A2N)是一个专为Linux环境设计的开源命令行工具,其主要功能在于帮助用户平滑地将原有的Apache配置转换为Nginx配置。这个工具旨在简化迁移过程,使得在性能优化、负载均衡或资源管理等方面有更高需求...

    php apache/nginx

    3. `apache_get_version`:获取Apache服务器的版本信息,有助于识别服务器的兼容性和配置问题。 4. `apache_getenv`:获取Apache子进程中环境变量的值,这对于检查和调试服务器环境是必要的。 5. `apache_lookup_...

    Nginx超过Apache10倍的配置方法

    文中对比了Nginx与Apache在同一负载下处理请求的能力,Nginx在每秒处理的请求数和系统负载方面都表现出优越性,表明在高并发场景下,Nginx具有更高的效率和稳定性。 总结来说,Nginx凭借其高效的事件驱动模型和对...

    实战Nginx取代Apache的高性能Web服务器_文字版

    2. PHP配置:在Nginx配置中,`location`块内添加`fastcgi_pass`指令指定PHP-FPM监听的地址。 3. PHP参数传递:`fastcgi_param`指令设置环境变量,如`SCRIPT_FILENAME`用于传递PHP脚本路径。 六、日志管理和优化 1....

    nginx 官网配置.pdf

    根据提供的文件信息,我们将详细探讨Nginx的配置要点,同时兼顾其作为Web服务器和反向代理服务器的特点。Nginx是一个高性能的HTTP和反向代理服务器,由Igor Sysoev编写,最初用于俄罗斯访问量第二大的网站rambler.ru...

    Linux+Apache+Nginx+Mysql+PHP完美配置教程

    【Linux+Apache+Nginx+Mysql+PHP完美配置教程】 在配置Linux服务器以支持LAMP(Linux, Apache, MySQL, PHP)环境时,我们需要进行一系列的准备工作和安装步骤。以下是一个详细的步骤指南: **一、准备工作** 1. *...

    Nginx+Apache负载均衡

    - **高性能负载均衡**:Nginx+Apache 组合提供了一个高性能、低成本的负载均衡解决方案,能够显著提高网站性能和服务可用性。 - **易于配置与管理**:相比昂贵的商用硬件负载均衡器,Nginx 的配置更加简单直观。 - *...

    php运行环境搭建(apache nginx)

    这里我们关注的是两种常见的服务器环境配置:Apache和Nginx,这两种服务器软件与PHP和MySQL的集成。这两种环境配置都能为PHP提供稳定且高效的运行平台。 **Apache + PHP + MySQL** Apache是世界上最流行的Web...

    nginx搭建配置详细说明

    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 ...

Global site tag (gtag.js) - Google Analytics