首页 > 其他 > 详细

nginx log打印自定义头

时间:2016-01-20 15:44:22      阅读:278      评论:0      收藏:0      [点我收藏+]

一、客户端自定义头

        如果客户端自定义了一个头。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打印自定义头

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!