오늘의 인기 글
최근 글
최근 댓글
Today
Total
05-05 00:02
관리 메뉴

우노

[Nginx] proxy_pass 시 custom header 추가 본문

Web/Nginx

[Nginx] proxy_pass 시 custom header 추가

운호(Noah) 2023. 3. 28. 11:26

예제 코드) proxy_pass 시 custom header 추가

server {
    listen   3002;
    root     /opt/nginx/html;
    resolver 168.126.63.1 valid=1m ipv6=off;

    # Disabling cache so the browser won't cache the website
    expires           0;
    add_header        Cache-Control private;

    location / {

        # 변수 생성(헤더 값)
        set $customheader 'hello';

        proxy_pass http://localhost:3000/;

        # 헤더 이름, 헤더 값 추가
        proxy_set_header customheader $customheader;

    }

    error_page 404 /404.html;
        location = /40x.html {
    }

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

'Web > Nginx' 카테고리의 다른 글

[Nginx] proxy_pass 시 cookie 전달  (0) 2023.03.30
[Nginx] 변수 사용 방법  (0) 2023.03.27
[Nginx] Json 로그 포맷 설정  (0) 2023.03.11
[Nginx] resolver란?  (0) 2023.02.23
[Nginx] 정규표현식  (1) 2023.02.17
Comments