0%

Nginx配置多个https域名

目标:nginx配置多个https域名

查看nginx是否支持支持TLS协议的SNI扩展
1
2
3
4
5
6
7
 root@iZj6cgoyl5x6opizfwaukrZ:~# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.17.0
built by gcc 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
built with OpenSSL 1.1.1 11 Sep 2018
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl-opt=enable-tlsext --with-pcre=./pcre-8.35
root@iZj6cgoyl5x6opizfwaukrZ:~#

 如果出现上面的TLS SNI support enabled,则略过第一步

更新nginx
1
2
3
4
5
6
[root]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
[root]# tar zxvf nginx-1.12.0.tar.gz
[root]# cd nginx-1.12.0
[root]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module \
--with-openssl=./openssl-1.0.2k \
--with-openssl-opt="enable-tlsext"

 其中openssl一般系统自带,可不添加
命令实行后建议,备份nginx.conf,进行重新安装,即make install

增加nginx的配置

直接增加server级的ssl配置即可