码迷,mamicode.com
首页 > 其他好文 > 详细

nginx log打印自定义头

时间:2016-01-20 15:46:00      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:access   配置文件   request   status   服务端   

一、客户端自定义头

        如果客户端自定义了一个头。curl -H "wanwan: nihao1111" 192.168.1.192:8888,那么nginx服务端是怎么显示的呢?nginx.conf配置文件log_format添加$http_wanwan(此时的wanwan就是客户端添加的头信息)


二、举例说明

1.主配置

#vim /usr/local/nginx/conf/nginx.conf
    log_format  access  ‘$remote_addr - $remote_user [$time_local] "$request" ‘
    ‘$status $body_bytes_sent "$http_referer" ‘
    ‘"$http_user_agent" $http_x_forwarded_for ‘
    ‘"$upstream_addr" "$upstream_status" "$upstream_response_time" "$request_time" 
    "$http_wanwan" ‘;
    include /usr/local/nginx/conf/vhost/*.conf;

 

2、vhost中配置文件

#vim /usr/local/nginx/conf/vhost/web.conf
server
{
      listen 80 default;
      server_name www.it300.com;
      index index.html index.htm index.php;
      root /data/httpd/it300.com;
      location ~ .*\.php?$
      {
   include fastcgi.conf;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
      }
      location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
      {
      expires 30d;17      }
      location ~ .*\.(js|css)?$
      {
      expires 1h;
      }
      access_log /data/logs/it300.com.log access;
     }

本文出自 “自动运维” 博客,请务必保留此出处http://whf191.blog.51cto.com/5763502/1736813

nginx log打印自定义头

标签:access   配置文件   request   status   服务端   

原文地址:http://whf191.blog.51cto.com/5763502/1736813

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!