我在 vps 上面搭建了一个网盘,并启用了 lets-encrypt https 加密访问,但是现在我只要是打开 example.com 或者是 www.example.com 都是显示您的连接不是私密连接,在域名面前加 https:// 访问就正常,请问如何设置访问域名强制 https 访问?
1
lhx2008 2019-12-23 15:42:27 +08:00 via Android
跳转
|
2
fever 2019-12-23 15:42:50 +08:00
nginx 没跳转?
|
3
tankren 2019-12-23 15:43:17 +08:00
搜 nginx force https
|
4
manami 2019-12-23 15:49:20 +08:00 1
nginx
```` server { listen 80; server_name test.com www.test.com; #填写绑定证书的域名 rewrite ^(.*)$ https://$host$1 permanent; #把 http 的域名请求转成 https } ```` |
5
x66 2019-12-23 16:00:00 +08:00
server {
listen 80; server_name localhost; rewrite ^(.*)$ https://$host$1 permanent; } |
6
ceet 2019-12-23 17:54:13 +08:00
```
server_name aiylqy.com www.aiylqy.com; if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; } ``` |
7
qiandongdong OP |