【问题标题】:Can I use both HTTP and HTTPS in nginx upstream?我可以在 nginx 上游同时使用 HTTP 和 HTTPS 吗?
【发布时间】:2019-07-11 00:55:02
【问题描述】:

我的 Nginx 配置如下:

upstream staging {
    server myappstaging.somedomain.com;
}

upstream prod {
    server myapp.somedomain.com:443;
}

# map to different upstream backends based on header
map $http_x_server_select $pool {
    default "prod";
    staging "staging";
}

server {
    listen 80;
    server_name myapp.mydomain.com;

    location / {
        proxy_pass https://$pool;
    }
}

我想将带有 x-server-select 标头的请求转发到 staging 到 http://myappstaging.somedomain.com 并将 prod 到 https://myapp.somedomain.com:443

Nginx 可以做到吗?

【问题讨论】:

    标签: http nginx https


    【解决方案1】:

    将方案作为变量的一部分。

    例如:

    map $http_x_server_select $pool {
        default "https://prod";
        staging "http://staging";
    }
    

    还有:

    proxy_pass $pool;
    

    【讨论】:

      猜你喜欢
      • 2015-05-18
      • 2020-12-01
      • 2019-03-06
      • 2023-04-02
      • 2016-05-23
      • 2020-12-03
      • 2017-02-16
      • 2017-07-23
      • 1970-01-01
      相关资源
      最近更新 更多