【问题标题】:how do i get upstream server url in nginx我如何在 nginx 中获取上游服务器 url
【发布时间】:2015-03-26 18:49:47
【问题描述】:

我正在尝试将主机标头设置为上游服务器 url。因此,如果根据要求选择了第二台服务器。我要proxy_setheader主机upstreamServerNname...

我尝试过使用变量,由于某种原因它是空的。 $server_addr 给出了 nginx 服务器本身的地址。

【问题讨论】:

    标签: nginx server load-balancing


    【解决方案1】:

    尝试使用$host 变量。

    proxy_set_header        Host            $host;
    

    $主机

    按此优先顺序:请求行中的主机名,或“Host”请求标头字段中的主机名,或服务器名称 匹配请求

    来源:http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

    【讨论】:

    • 请求主机头指向负载均衡器而不是随机选择的上游服务器
    • 你能包含你的配置吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2011-08-13
    • 2017-03-16
    • 2021-06-14
    • 2017-12-27
    • 1970-01-01
    • 2012-09-08
    相关资源
    最近更新 更多