小编moh*_*han的帖子

在 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
        }

   }
Run Code Online (Sandbox Code Playgroud)

//备份系统

server{
        listen  777;
        server_name     _;
        #doing some other extra stuf

        #use port and protocol to direct
}
Run Code Online (Sandbox Code Playgroud)

谢谢

http nginx http-headers

6
推荐指数
1
解决办法
3万
查看次数

标签 统计

http ×1

http-headers ×1

nginx ×1