nginx虚拟主机日志配置问题

回复 收藏

nginx.conf 下的日志格式配置

user admin admin;

worker_processes 8;

error_log /usr/local/nginx/logs/nginx_error.log warn;

pid /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile 65535;

events

{

    use epoll;

    worker_connections 65535;

}

http

{

 include mime.types;

    default_type application/octet-stream;

    server_names_hash_bucket_size 3526;

    server_names_hash_max_size 4096;

    log_format hewj '$remote_addr $http_x_forwarded_for [$time_local]'

    '$host "$request_uri" $status'

    '"$http_referer" "$http_user_agent"';

    access_log  logs/host.access.log  combined_realip;

    tcp_nopush on;

    keepalive_timeout 30;

    client_header_timeout 3m;

    client_body_timeout 3m;

    send_timeout 3m;

    connection_pool_size 256;

    client_header_buffer_size 1k;

    large_client_header_buffers 8 4k;

    request_pool_size 4k;

    output_buffers 4 32k;

    postpone_output 1460;

    client_max_body_size 10m;

    client_body_buffer_size 256k;

    client_body_temp_path /usr/local/nginx/client_body_temp;

    proxy_temp_path /usr/local/nginx/proxy_temp;

    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;

    fastcgi_intercept_errors on;

    tcp_nodelay on;

    gzip on;

    gzip_min_length 1k;

    gzip_buffers 4 8k;

    gzip_comp_level 5;

    gzip_http_version 1.1;

    gzip_types text/plain application/x-javascript text/css text/htm appl

ication/xml;

 include vhosts/*.conf;

    }

vhosts/*.conf 下的引用

access_log /home/logs/discuz_access.log combined_realip;

为什么总是报错呢

[root@hewj1 vhosts]# /usr/local/nginx/sbin/nginx -t            

nginx: [emerg] unknown log format "combined_realip" in /usr/local/nginx/conf/nginx.conf:22

nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

将vhosts/*.conf 下的引用注释后#access_log /home/logs/discuz_access.log combined_realip;就不报错了

在主配置文件中添加了  

include vhosts/*.conf;   也不行

请高手指教。

2017-02-03 13:35 举报
已邀请:
0

阿铭 管理员

赞同来自:

combined_realip  这个是日志的格式名字。 需要你在nginx.conf中去定义这个格式。

 log_format hewj '$remote_addr $http_x_forwarded_for [$time_local]'

    '$host "$request_uri" $status'

    '"$http_referer" "$http_user_agent"';

这就这段,你的格式名字叫做  hewj   你应该改成 combined_realip

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: