nginx 基本使用

nginx

配置

Nginx 实现 HTTP 自动跳转到 HTTPS 页面

建议在 Nginx 虚拟主机配置文件对应的网站配置段中增加跳转项 if...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server
{
listen 80;
server_name www.websoft9.com;
index readme.html index.html index.htm;
root /data/nas/www.websoft9.com;
error_log /var/log/nginx/www.websoft9.com-error.log crit;
access_log /var/log/nginx/www.websoft9.com-access.log;
include conf.d/extra/*.conf;

# HTTP to HTTPS
if ($scheme = http) {
return 301 https://$host$request_uri;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.websoft9.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.websoft9.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

参考

Nginx从安装到高可用,一篇搞定!

免费证书

nginx实践

打赏
  • © 2015-2024 DXShelley
  • Powered by Hexo Theme Ayer

请我喝杯咖啡吧~~~

支付宝
微信