nginx虚拟主机日志配置问题

回复 收藏
本帖最后由 qq20847697 于 2015-5-14 22:03 编辑

nginx.conf 下的日志格式配置
    log_format combined_realip '$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;

vhosts/*.conf 下的引用
access_log /home/logs/discuz_access.log combined_realip;


为什么总是报错呢
[root@localhost /]# /usr/local/nginx/sbin/nginx -t
nginx: [emerg] unknown log format "combined_realip" in /usr/local/nginx/conf/vhosts/aaa.conf:45
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed



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

直接在nginx.conf 下引用也不报错,如下第四行
    log_format combined_realip '$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;


头太晕了,搞死人了,谁是明白人指点下啊!!!

2015-05-14 22:00 举报
已邀请:
0

阿铭 管理员

赞同来自:

你把整个配置都发出来吧,实在不行把你的discuz.conf 放到nginx.conf里面去试试看。
0

qq20847697

赞同来自:

阿铭 发表于 2015-5-14 22:12
你把整个配置都发出来吧,实在不行把你的discuz.conf 放到nginx.conf里面去试试看。

discuz.conf 放到nginx.conf里面去,配置正常了,为什么单独放到虚拟主机就不行呢
0

qq20847697

赞同来自:

找到原因了
http
{
#   include vhosts/*.conf;
include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$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;
    sendfile on;
    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 application/xml;
include vhosts/*.conf;

include vhosts/*.conf; 这个放到http的后面去才能生效
0

定海偶然

赞同来自:


上课好像有讲到过的吧.
0

Ject1992he - linux学习

赞同来自:

include vhosts/*.conf; 这个放到http的后面也不能生效,求指教。

回复帖子,请先登录注册

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