Nginx 설정 access log 요청 로그 상세 설명

2130 단어 linuxnginx
설정 예제
log_format main '$remote_addr - $remote_user [$time_local] '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent" "$http_x_forwarded_for"';

access_log logs/access.log main;

log_형식 명령 어
기본 값: log_format combined "...";탭 위치: http상용 변수:
  • $bytes_sent 클 라 이언 트 에 게 보 낸 바이트 수 는 ngx 에 있 습 니 다.http_log_module
  • $request_length 요청 길이 (요청 줄, 헤더, 요청 본문 포함), ngxhttp_log_module
  • $request_time 은 밀리초 단위 의 처리 시간 을 요구 하 며, ngx 에 있 습 니 다.http_log_module
  • $status 상태 코드, ngx 에 위치http_log_module
  • $time_local 에서 요청 한 로 컬 시간 과 시내, ngxhttp_log_module
  • $remote_addr 클 라 이언 트 주소, ngxhttp_core_module
  • $remote_user Basic 권한 수여 모드 에서 클 라 이언 트 사용자 이름 은 ngx 에 있 습 니 다.http_core_module
  • $request 의 완전한 요청 주소 와 프로 토 콜 은 ngx 에 있 습 니 다.http_core_module
  • $request_body 가 요청 한 body 내용 은 ngx 에 있 습 니 다.http_core_module
  • $http_host 도 메 인 이나 IP
  • $http_referer 가 요청 한 점프 소스
  • $http_user_에이전트 브 라 우 저 정보
  • $http_x_forwarded_클 라 이언 트 주 소 를 기록 하 는 설정
  • 변수 에 대응 하 는 값 이 존재 하지 않 으 면 "- '대신.
    access_로그 명령
    기본 값: access_log logs/access.log combined;탭 위치: http, server, location, if in location, limit_except
    access_log off;
    access_log logs/access.log main;
    access_log logs/access.log main buffer=32k flush=5s;
    map $status $loggable {
        ~^[23]  0;
        default 1;
    }
    
    #  2xx   3xx         
    access_log /path/to/access.log main if=$loggable;

    다시 불 러 오기 설정
    ../sbin/nginx -t
    ../sbin/nginx -s reload

    참고: http://nginx.org/en/docs/http...
    http://nginx.org/en/docs/http...

    좋은 웹페이지 즐겨찾기