custom header 값을 nginx 로그로 찍기

2022. 10. 27. 19:06·DevOps/nginx
기본 http header들은 nginx 에서 제공하는 variable로 찍으면 되는데..어플리케이션에서 직접 생성한 `custom header` 는 어떻게 찍을까? 

 

 

우선 nginx 에서 지원하는 variable 리스트 중에 `$http_name` 이라는 값이 있다. 저 뒤 `_name` 부분에 custom 하게 생성한 header의 이름을 넣어주면 log에 기록할 수 있게 된다! 

 

log_format에 아래와 같이 추가해주면! 예쁘게 잘 찍힐것! 

log_format  main '$remote_addr $http_x_forwarded_for [$time_local] '
                     '$host $request $status $body_bytes_sent '
                     '$request_time $upstream_response_time '
                     '"$http_referer" "$http_user_agent" "$http_커스텀헤더명"';

 

저작자표시 비영리 변경금지 (새창열림)

'DevOps > nginx' 카테고리의 다른 글

모바일, PC 화면 Nginx로 분기 처리하는 방법  (2) 2023.01.04
[nginx] 서비스 점검공지 올리는 방법  (1) 2022.10.05
nginx를 사용해서 점검페이지를 띄워보자  (0) 2019.09.29
'DevOps/nginx' 카테고리의 다른 글
  • 모바일, PC 화면 Nginx로 분기 처리하는 방법
  • [nginx] 서비스 점검공지 올리는 방법
  • nginx를 사용해서 점검페이지를 띄워보자
bandal-gom
bandal-gom
Devops & Backend Developer | tech blog
  • bandal-gom
    yayz's devlog
    bandal-gom
  • 전체
    오늘
    어제
    • 분류 전체보기 (68)
      • DevOps (22)
        • devops (4)
        • cicd (2)
        • docker (2)
        • monitoring (2)
        • nginx (4)
        • cache (1)
        • aws (1)
        • etc (6)
      • BE (21)
        • BE (3)
        • design pattern (1)
        • data structure (0)
        • spring (1)
        • algorithm (12)
      • devlog (24)
        • TIL (17)
        • programming language (2)
        • conference (2)
        • etc (3)
      • IT Review (1)
  • 블로그 메뉴

    • about.
    • 개발👩‍💻
    • etc.
  • 링크

    • Github
  • 공지사항

  • 인기 글

  • 태그

    til
    키캡
    jenkins
    노트북하기좋은카페
    항해99
    문제풀이
    티스토리챌린지
    homelab
    NGINX
    알고리즘
    프로그래머스
    코딩테스트준비
    algorithm
    array
    모각코
    젠킨스
    Programmers
    개발자취업
    java
    알고리즘문제풀이
    Kotlin
    99클럽
    오블완
    Python
    hash
    릿코드
    키보드케이블
    leetcode 347
    LeetCode
    time complexity
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.1
bandal-gom
custom header 값을 nginx 로그로 찍기
상단으로

티스토리툴바