如何在Nginx服务器上安装SSL证书(nginx,ssl,web开发)

时间:2024-05-09 23:20:12 作者 : 石家庄SEO 分类 : web开发
  • TAG :

在Nginx服务器上安装SSL证书

配置nginx

1.下载证书文件
如何在Nginx服务器上安装SSL证书

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服务器上安装SSL证书

启动时nginx:[emerg]unknown directive ssl错误

原因是nginx缺少SSL模块,需要重新将SSL模块添加进去,然后再启动nginx:

  1. 在解压目录(不是安装目录)执行命令:./configure --with-http_ssl_module

  2. 继续执行命令:make

  3. 将objs目录下的nginx文件复制到/usr/local/nginx/sbin/下覆盖,然后重新启动即可。

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:如何在Nginx服务器上安装SSL证书的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:怎么用Nginx配置web服务器下一篇:

5 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18