在 nginx 中将 http 重定向到 https
如何在 nginx 配置中将 http 流量重定向到 https。
server {
listen 80;
server_name domain.name;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate domain.name.crt;
ssl_certificate_key domain.name.key;
server_name domain.name;
location / {
...
}
}
参考资料