1

这篇文章非常接近我正在寻找的内容。但我正在寻找的是

letsencrypt.example.com   should always be http
          *.example.com   should always be https

使用这篇文章中的解决方案,我可以通过以下方式将所有 http 重写为 https

server {
  listen 80;
  server_name test.example.com;
  rewrite     ^   https://$http_host$request_uri? permanent;
}

然后再做

server {
  listen 443 ssl;
  ...

问题

但是我怎样才能确保它letsencrypt.example.com仍然在 http 端口 80?

4

1 回答 1

1

您应该使用显式服务器进行letsencrypt.example.com重定向,然后使用包罗万象的服务器进行重定向。

您的 80 端口服务器块看起来像这样:

server {
    listen 80;
    server_name letsencrypt.example.com;
    ...
}
server {
    listen 80 default_server;
    return 301 https://$http_host$request_uri;
}

有关详细信息,请参阅此文档

于 2016-05-19T12:59:36.433 回答