NGINX 학습 노트 - 전달 요청 헤드

1936 단어 구조 설계Linux
원본 주소:https://www.nginx.com/resources/admin-guide/reverse-proxy/ 본문 제목: Passing Request Headers
기본적으로 NGINX 는 프 록 시 요청 시 HTTP 헤드 필드 두 개 를 'Host' 와 'Connection' 으로 다시 정의 하고 값 이 비어 있 는 헤드 필드 를 삭제 합 니 다.'Host' 는 $proxy_host 변수의 값 으로, 'Connection' 은 close 로 설정 된다.By default, NGINX redefines two header fields in proxied requests, “Host” and “Connection”, and eliminates the header fields whose values are empty strings. “Host” is set to the $proxy_host variable, and “Connection” is set to close.
이 설정 을 변경 하려 면 다른 헤드 필드 를 수정 하고 proxy_set_header 명령 을 사용 하 십시오.이 명령 은 location 또는 더 높 은 층 에서 사용 할 수 있다.특정한 server 컨 텍스트 나 http 블록 에서 도 가능 합 니 다. 예 를 들 어 To change these setting, as well as modify other header fields, use the proxyset_header directive. This directive can be specified in a location or higher. It can also be specified in a particular server context or in the http block. For example:
location /some/path/ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:8000;
}

이 설정 에서 "Host" 필드 는 $host 변수 로 설정 되 었 습 니 다.In this configuration the “Host” field is set to the $host variable.
프 록 시 서버 에 헤더 필드 가 전달 되 는 것 을 막 으 려 면 빈 문자열 로 설정 하 십시오.To prevent a header field from being passed to the proxied server, set it to an empty string as follows:
location /some/path/ {
    proxy_set_header Accept-Encoding "";
    proxy_pass http://localhost:8000;
}

좋은 웹페이지 즐겨찾기