带有服务器指令的nginx映射。 转发http – > https

我有7个服务。 我希望他们自动转发http-> https。

我正在尝试这个,但它不工作:

map $http_host $backend { apples.example.com http://127.0.0.1:3006; oranges.example.com http://127.0.0.1:3000; bananas.example.com http://127.0.0.1:3010; pears.example.com http://127.0.0.1:3012; dragonfruit.example.com http://127.0.0.1:3014; peaches.example.com http://127.0.0.1:3002; tomatos.example.com http://127.0.0.1:3016; } # All services (except button) forward HTTP -> HTTPS server { listen 80; return 307 https://$http_host$request_uri; } 

我误解了一些东西,因为其中一个服务不匹配。

http://apples.example.com正在转发到https://peaches.example.com

我正在运行这个testing:

 sudo service nginx restart && wget http://apples.example.com/ --no-check-certificate 

它正在返回:

 --2016-10-05 20:07:37-- http://apples.example.com/ Resolving expert-dev.bigsmall.io (apples.example.com)... 127.0.0.1 Connecting to expert-dev.bigsmall.io (apples.example.com)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 307 Temporary Redirect Location: https://peaches.example.com [following] --2016-10-05 20:07:37-- https://peaches.example.com/ 

nginx版本:nginx / 1.10.0(Ubuntu)

有什么build议么?