Redirecting to SSL using nginx

前端 未结 5 1709
傲寒
傲寒 2020-12-08 16:29

I have http:// and https:// on the same host like the following:

server {

    listen   80;
    listen   443 ssl;

    ...
    ...
}

What I

5条回答
  •  长情又很酷
    2020-12-08 16:52

    Ideally, avoiding if statements while preserving the trailing path:

    server {
      listen 80;
      server_name example.com;
      rewrite (.*) https://example.com$1 permanent;
    }
    

    permanent takes care of the 301.

提交回复
热议问题