Rewrite HTTP to HTTPS in Nginx

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

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;
       ...
}

 

posted @ 2018-07-14 18:00  yudis  阅读(87)  评论(0编辑  收藏  举报