Rewrite HTTP to HTTPS in Nginx

1.推薦配置

server {
       listen         80;
       server_name    example1.com example2.com;
       return         301 https://$host$request_uri;
}

server {
       listen         443 ssl;
       server_name    example1.com example2.com;
       ...
}

2.爲何使用$host

  • $host is used instead of $server_name to properly match between server block the corresponding domains

3.照搬連接

相關文章
相關標籤/搜索