nginx添加ssl模块配置https
先安装c环境:
yum -y install gcc
yum -y install gcc-c++
一.安装nginx
-
解压nginx安装包
tar -zxvf nginx-1.16.1.tar.gz -
把解压的出来的移动到/usr/local/nginx中
mv nginx-1.16.1 /usr/local/nginx -
进入/usr/local/nginx目录
-
执行配置编译ssl模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
- 安装 pcre
yum -y install pcre-devel openssl openssl-devel - 编译
make && make install
二。进行https配置
- 准备key文件和pem文件,复制到/usr/local/nginx/路径下面
2. 配置 .conf文件
在server{…
…
}
里面加上下面代码
listen 443 ssl;
client_max_body_size 800M;
server_name elevator.hzsdtech.com;
ssl_certificate /usr/local/nginx/sslpem.pem;
ssl_certificate_key /usr/local/nginx/sslkey.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
- 启动nginx
cd /usr/local/nginx/sbin/
./nginx