关于nginx多域名SSL证书的工作笔记

 
  
  
  
  
  1. 如何为服务器生成SSL证书文件? 
  2.  
  3.  openssl genrsa -des3 -out nginx.key 2048 
  4.  openssl req -new -key nginx.key -out nginx.csr 
  5.  cp nginx.key nginx.key.org 
  6.  openssl rsa -in nginx.key.org -out nginx.key 
  7.  openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt 
  8.  
  9.  
  10. SSL 证书配置规划: 
  11.  
  12. 一、检查系统是否支持SSL 
  13.  
  14. 上传完配置文件后,如果发现出现类似提示,请检查一下是否有编译SSL选项 
  15. # /usr/local/nginx/sbin/nginx -t 
  16. nginx: [emerg] unknown directive "ssl" in /usr/local/nginx/conf/vhost/nginx.conf:8 
  17. nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed 
  18.  
  19. # /usr/local/nginx/sbin/nginx -V 
  20. nginx version: nginx/1.0.12 
  21. built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48) 
  22. configure arguments: --user=nobody --group=nobody --prefix=/usr/local/nginx \
  23. --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module \
  24. --with-http_sub_module --add-module=./nginx-upstream-jvm-route/ --with-pcre=/root/pcre-8.12 
  25.  
  26. 二、如果你有多个不同域名的证书,则需要重新编译openssl,以获得TLS SNI支持 
  27.  
  28. # wget   http://www.openssl.org/source/openssl-0.9.8l.tar.gz 
  29. # tar zxvf ./openssl-0.9.8l.tar.gz 
  30. # cd ./openssl-0.9.8l 
  31. # ./config enable-tl***t 
  32. # make && make install  
  33.  
  34. 需要重新编译:  
  35. #  ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx \  
  36. --with-http_stub_status_module --with-http_gzip_static_module \  
  37. --with-http_realip_module --with-http_sub_module --add-module=./nginx_upstream_jvm_route/ \  
  38. --with-pcre=/root/pcre-8.12 --with-http_ssl_module --with-openssl=/root/openssl-0.9.8l/ 
  39. # make  
  40. # make install  
  41.  
  42. 编译完成以后,查看是否支持下TLS,SNI 
  43. # /usr/local/nginx/sbin/nginx -V 
  44. nginx version: nginx/1.0.12 
  45. built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52) 
  46. TLS SNI support enabled 
  47. configure arguments: --user=nobody --group=nobody --prefix=/usr/local/nginx \
  48. --with-http_stub_status_module --with-http_gzip_static_module \
  49. --with-http_realip_module --with-http_sub_module --add-module=./nginx_upstream_jvm_route/ \
  50. --with-pcre=/root/pcre-8.12 --with-http_ssl_module --with-openssl=/root/openssl-0.9.8l/ 
  51.  
  52.  
  53.  
  54. 1、在本机上备份证书、私钥、针对每个域名的配置文件  
  55. 2、在本机nginx上部署应用,视情况开启rewrite 
  56. 3、要求每个反向代理节点都可以 

 

本文出自 “潜入技术的海洋” 博客,请务必保留此出处http://myhat.blog.51cto.com/391263/885944

你可能感兴趣的:(nginx,SSL证书,多域名)