【问题标题】:Redirect all but one sub domain to https?将除一个子域之外的所有子域重定向到 https?
【发布时间】:2016-09-16 02:39:17
【问题描述】:

This 帖子非常接近我正在寻找的内容。但我正在寻找的是

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

使用this post中的解决方案,我可以将所有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 上?

【问题讨论】:

    标签: linux redirect nginx https lets-encrypt


    【解决方案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;
    }
    

    详情请见this documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 2012-06-03
      • 1970-01-01
      • 2013-08-24
      • 2015-04-26
      • 2018-02-06
      • 1970-01-01
      相关资源
      最近更新 更多