nginx支持多域名SSL配置

来源:互联网 发布:apache tomcat7.0下载 编辑:程序博客网 时间:2024/04/30 01:37

openssl下载: http://www.openssl.org/source/   版本:1.0.0

 如果你有多个不同域名的证书,则需要重新编译openssl,以获得TLS SNI支持 
 
# tar zxvf ./openssl-0.9.8l.tar.gz 
# cd ./openssl-0.9.8l 
# ./config enable-tl***t 
(不需要安装)

1.注意:OPENSSL不需要安装,只需要解压出来就行。不然在编译时会提示类似以下的错误:

make[1]: Entering directory `/root/nginx-0.7.65'
cd /server/openssl \
        && make clean \
        && ./config --prefix=/server/openssl/openssl no-shared  no-threads \
        && make \
        && make install
make[2]: Entering directory `/server/openssl'
make[2]: *** No rule to make target `clean'.  Stop.
make[2]: Leaving directory `/server/openssl'
make[1]: *** [/server/openssl/openssl/include/openssl/ssl.h] Error 2
make[1]: Leaving directory `/root/nginx-0.7.65'
make: *** [build] Error 2

 

2.安装Nginx的时候,把openssl路径指定到解压出来的路径:

./configure  --with-http_stub_status_module --with-http_ssl_module --with-openssl=/root/openssl-1.0.0 --with-http_gzip_static_module 

make&&make install

生成证书

$ cd /usr/local/nginx/conf
$ openssl genrsa -des3 -out server.key 1024
$ openssl req -new -key server.key -out server.csr
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

编辑 nginx.conf

server {
    server_name YOUR_DOMAINNAME_HERE;
    listen 443;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/server.key;
  ***********
(nginx其它配置)
  **********
}

3.在iptables中打开ssl使用到的443端口,重启iptables.




0 0
原创粉丝点击