markdown https和nginx重定向
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown https和nginx重定向相关的知识,希望对你有一定的参考价值。
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04
Redirect everything to SSL (personal config on UNIX with IPv4, IPv6, SPDY, ...):
http://stackoverflow.com/a/11733363/2172151
```
#
# Redirect all www to non-www
#
server {
server_name www.example.com;
ssl_certificate ssl/example.com/crt;
ssl_certificate_key ssl/example.com/key;
listen *:80;
listen *:443 ssl spdy;
listen [::]:80 ipv6only=on;
listen [::]:443 ssl spdy ipv6only=on;
return 301 https://example.com$request_uri;
}
#
# Redirect all non-encrypted to encrypted
#
server {
server_name example.com;
listen *:80;
listen [::]:80;
return 301 https://example.com$request_uri;
}
#
# There we go!
#
server {
server_name example.com;
ssl_certificate ssl/example.com/crt;
ssl_certificate_key ssl/example.com/key;
listen *:443 ssl spdy;
listen [::]:443 ssl spdy;
# rest goes here...
}
```
Comprobar
```
curl -I http://www.example.com
```
以上是关于markdown https和nginx重定向的主要内容,如果未能解决你的问题,请参考以下文章
markdown [www和https重定向]将所有文件重定向到https url和www域名#www #htaccess
markdown Chrome中的dev和foo域扩展程序强制重定向到HTTPS备注
将 HTTP 重定向到 HTTPS(中间件重定向 vs Nginx)
markdown HAProxy - 将http重定向到https
带有 HTTPS 重定向的 Nginx 入口控制器尾部斜杠
nginx开启ssl并把http重定向到https的两种方式