Ubuntu Nginx https 配置

#配置http跳转到https 80跳转443
server { listen
80; server_name www.***.com www.***.cn; return 301 https://$server_name$request_uri; }
#配置https server { listen
443; server_name www.***.com www.***.cn; index index.html index.php; root /var/www/php/demo; ssl on; ssl_certificate https_keys/1_www.***.com_bundle.crt; ssl_certificate_key https_keys/2_www.***.com.key; error_log /log/error/error.log; access_log /log/access/access.log; include common.conf; }

 上面的代码是 nginx server 中的配置 https 配置 如果访问的是http 直接跳转 https

我将https 协议的 key 和crt 文件到了https_keys 中 

几点注意事项:
1. 如果HTTPS方式访问网站出现无响应的情况,可以看看自己的服务器防火墙配置,是不是需要将443端口加到例外中去; 
2. 注意自己xxx.pemxxx.key的存放路径,区分相对路径和决定路径使用方式; 
3. 通过Nginx安装目录下的logs文件夹中的access.logerror.log日志文件来进行排错; 
4. 同一个Nginx可以配置多个HTTPS的域名,只需要将上面443端口的监听配置复制一份加到配置文件中,然后修改好相应的server_namexxx.pemxxx.key文件路径即可。

 

posted @ 2018-08-24 18:35  Func~  阅读(313)  评论(0编辑  收藏  举报