두 시스템 (모두 nginx로드 밸런서와 백업 역할 중 하나)을 사용하고 있습니다. 몇 가지 http 사용자 정의 헤더를 추가하고 사용하고 싶습니다. 헤더 그냥 추가 할 위치 블록에 다음 코드를 추가 추가하려면nginx에서 헤더 (HTTP) 추가 및 사용
예를 들어, 귀하의 제안
upstream upstream0{
#list of upstream servers
server backend:80;
server backup_load_balancer:777 backup;
#healthcheck
}
server{
listen 80;
#Add custom header about the port and protocol (http or https)
server_name _;
location/{
proxy_pass "http://upstream0;#" is included since links are not allowed in the post
}
}
// 백업 시스템
server{
listen 777;
server_name _;
#doing some other extra stuf
#use port and protocol to direct
}
감사
감사합니다. 다른 청취자에게 어떻게 읽습니까? – mohan
$ http_HEADER 및 $ send_http_HEADER 변수는 nginx의 헤더 내용에 액세스 할 수 있습니다. http://wiki.nginx.org/HttpCoreModule#Variables – cobaco
'proxy_pass'가 사용될 때'add_header'가 작동합니까? 이 질문은 그것과 모순되는 것 같습니다 : http://stackoverflow.com/questions/14501047/how-to-add-a-response-header-on-nginx-when-using-proxy-pass –