Nginx 역방향 에이전트 해결 시 headers 가 잘못 되 었 습 니 다.

1245 단어 linux공구.
nginx 역방향 에이전트 기본 행동
  • Nginx 는 역방향 대 리 를 할 때 host 와 ip 를 설정 합 니 다. 요청 한 headers 에 값 이 있 으 면 동시에 전송 할 수 있 습 니 다
  • 질문
  • 가끔 우 리 는 역방향 대 리 를 할 때 어떤 header 를 얻 지 못 하 는 것 을 발견 할 수 있다. 이 유 는 기본 적 인 상황 에서 모든 headers fields 이 퍼 가기 되 는 것 이 아니 라 fields 에 밑줄 (_) 이 있 는 것 이 고 Nginx 는 불법 으로 간주 되 며 보 내지 않 기 때문이다.예 를 들 어 다음 과 같다.
    access_token: this is your token
    
  • 공식 문서 의 해석:
    Syntax: underscores_in_headers on | off; Default: underscores_in_headers off; Context: http, server Enables or disables the use of underscores in client request header fields. When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive.
    문서 에서 설명: 밑줄 친 _ headers fields 을 지원 하려 면 underscores_in_headerson 로 설정 해 야 합 니 다.그것 만 설정 하면 소 용이 없습니다. proxy_pass_request_headers on;
  • 을 설치 해 야 하기 때 문 입 니 다.
  • 완전한 해결 방안 은 다음 과 같다.
    server {
    	...
    	underscores_in_headers on;
    	
    	location / {
    		proxy_pass_request_headres on;
    		proxy_pass http://server;
    	}
    }
    
  • 좋은 웹페이지 즐겨찾기