最近折腾的web应用比较多,在nginx使用中踩了不少坑,记录一下,以便以后查询
☆安装
1 | apt update |
☆配置文件路径
/etc/nginx/conf.d
建议每个站点单独建一个 ***.conf
放在此目录
☆ssl证书位置
默认相对目录为 /etc/nginx ,建议新建一个目录来存放,如 /etc/nginx/cert,
则在配置中填写为: cert/证书名
亦可将证书放在其他地方,配置文件中使用绝对路径
☆http配置
1 | server { |
☆https配置
1 | server { |
☆反向代理配置
1 | location / { |
☆http 强制重定向到https
rewrite ^ https://$http_host$request_uri? permanent;
☆检查配置问题
nginx -t
☆重启服务
service nginx restart