如何在Nginx服务器上安装SSL证书
导读:本文共1357字符,通常情况下阅读需要5分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 在Nginx服务器上安装SSL证书 配置nginx 1.下载证书文件 2.在nginx的conf目录中创建目录cert目录,并将证书文件拷贝进去。 3.配置nginx.conf,完整的nginx.conf如下:#usernobody;worker_processes1;#error_loglogs/error.lo... ...
音频解说
目录
(为您整理了一些要点),点击可以直达。在Nginx服务器上安装SSL证书
配置nginx
1.下载证书文件
2.在nginx的conf目录中创建目录cert目录,并将证书文件拷贝进去。
3.配置nginx.conf,完整的nginx.conf如下:
#usernobody;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events{worker_connections1024;}http{includemime.types;default_typeapplication/octet-stream;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#access_loglogs/access.logmain;sendfileon;#tcp_nopushon;#keepalive_timeout0;keepalive_timeout65;#gzipon;server{listen80;server_namexxx.com;#替换成你的域名location/{rewrite^(.*)$https://xxx.com/$1permanent;#替换成你的域名}}server{listen443;server_namexxx.com;#替换成你的域名sslon;#设置为on启用SSL功能。roothtml;indexindex.htmlindex.htm;ssl_certificatecert/2946730_www.xxx.com.pem;#替换成你的pem文件名称ssl_certificate_keycert/2946730_www.xxx.com.key;#替换成你的key文件名称ssl_session_timeout5m;ssl_ciphersECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;#使用此加密套件。ssl_protocolsTLSv1TLSv1.1TLSv1.2;#使用该协议进行配置。ssl_prefer_server_cipherson;location/{proxy_passhttp://localhost:8080/;#请求转发}}}
4.启动nginx,然后进行访问:
启动时nginx:[emerg]unknown directive ssl错误
原因是nginx缺少SSL模块,需要重新将SSL模块添加进去,然后再启动nginx:
在解压目录(不是安装目录)执行命令:./configure --with-http_ssl_module
继续执行命令:make
将objs目录下的nginx文件复制到/usr/local/nginx/sbin/下覆盖,然后重新启动即可。
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:
如何在Nginx服务器上安装SSL证书的详细内容,希望对您有所帮助,信息来源于网络。