Home Database Mysql Tutorial Nginx日志记录cookie

Nginx日志记录cookie

Jun 07, 2016 pm 03:10 PM
cookie nginx log Record Configuration

Nginx的配置就好像做程序一样,其实很好玩。 笔记一下: server { listen 80; server_name www.aslibra.com; set $aslibra_auth ; if ( $http_cookie ~* aslibra_auth=(.+)(?:;|$) ){ set $aslibra_auth $1; } log_format main $proxy_add_x_forwarded_for -

Nginx的配置就好像做程序一样,其实很好玩。

笔记一下:

server {
   listen       80;
   server_name   www.aslibra.com;
   set $aslibra_auth "";
   if ( $http_cookie ~* "aslibra_auth=(.+)(?:;|$)" ){
     set $aslibra_auth $1;
   }

   log_format main       '$proxy_add_x_forwarded_for - $remote_user [$time_local] '
           '"$request" $status $bytes_sent '
           '"$http_referer" "$http_user_agent" $aslibra_auth ';
   access_log   /Data/log/nginx-access.log   main;

   location / {
     root   /Data/webapps/www.aslibra.com/;
     index   index.html index.htm;
   }

   error_page   500 502 503 504   /50x.html;
   location = /50x.html {
       root   html;
   }

}



参考分割日志的脚本:

#!/bin/bash
log_dir="/Data/log"
time=`date +%Y%m%d`  
/bin/mv   ${log_dir}/nginx-access.log ${log_dir}/nginx-access.$time.log
kill -USR1 `cat   /var/run/nginx.pid`

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow external network access to tomcat server How to allow external network access to tomcat server Apr 21, 2024 am 07:22 AM

How to allow external network access to tomcat server

What are the nginx start and stop commands? What are the nginx start and stop commands? Apr 02, 2024 pm 08:45 PM

What are the nginx start and stop commands?

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

Welcome to nginx!How to solve it? Welcome to nginx!How to solve it? Apr 17, 2024 am 05:12 AM

Welcome to nginx!How to solve it?

How to solve the problem of nginx when accessing the website How to solve the problem of nginx when accessing the website Apr 02, 2024 pm 08:39 PM

How to solve the problem of nginx when accessing the website

How to deploy nodejs project to server How to deploy nodejs project to server Apr 21, 2024 am 04:40 AM

How to deploy nodejs project to server

How to register phpmyadmin How to register phpmyadmin Apr 07, 2024 pm 02:45 PM

How to register phpmyadmin

How to communicate between docker containers How to communicate between docker containers Apr 07, 2024 pm 06:24 PM

How to communicate between docker containers

See all articles