configurationURL的最佳方法是在Nginx中实施HTTPS?

有没有一种方法可以configurationNginx从一行一行的文件中读取,以确定何时应该执行HTTPS,而不是将所有的URL都放在条件检查中? 还是有办法把两者结合起来? 两个值得关注的领域是组织和长期pipe理这些url的能力。 我们正在考虑把它移到应用程序层,但Nginx在评估这个方面似乎更快。 目前我们只是使用正则expression式。

map $uri $example_com_preferred_proto { default "http"; ~^/sign-up/ "https"; ~^/account/ "https"; } server { listen 80; server_name example.com; if ($example_com_preferred_proto = "https") { return 301 https://example.com$request_uri; } # root /var/www/example.com/html; # other stuff # ... # location / { # ... # } }