我使用兩個系統(都是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 2012-08-15 17:28:38
$ http_HEADER和$ send_http_HEADER變量允許訪問nginx中標題的內容請參閱http://wiki.nginx.org/HttpCoreModule#Variables – cobaco 2012-08-15 17:42:09
當使用'proxy_pass'時'add_header'是否工作?這個問題似乎與它相矛盾:http://stackoverflow.com/questions/14501047/how-to-add-a-response-header-on-nginx-when-using-proxy-pass – 2016-03-21 15:46:39