查看Nginx版本和配置的模块
./nginx -V
安装依赖包
yum -y install gcc-c++ wget net-tools traceroute zip unzip sysstat tcpdump lrzsz nmap tree
安装OpenSSL
yum install openssl
yum install openssl-devel
配置Nginx
./configure --prefix=/opt/app/nginx --with-http_ssl_module
编译和安装
make - && make install
用新的执行文件替换旧的执行文件
安装包目录下的objs文件里面生成一个新的nginx文件,替换掉nginx/sbin/文件夹里面的nginx文件
生成证书
openssl genrsa -des3 -out www.XXX.com.key 2048
openssl rsa -in www.XXX.com.key -out www.XXX.com.key
openssl req -new -x509 -key www.XXX.com.key -out ca.crt -days 3650
openssl req -new -key www.XXX.com.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey www.XXX.com.key -CAcreateserial -out www.XXX.com.crt
添加证书
将.crt证书文件和.key私钥文件放在nginx/conf/文件夹
配置Nginx
server {
listen 443 ssl;
server_name IP;
ssl_certificate www.XXX.com.crt;
ssl_certificate_key www.XXX.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}