环境:centos 7.9
1、nginx/openssl下载 参考
一. gcc 安装
yum install gcc-c++
二. PCRE pcre-devel 安装
yum install -y pcre pcre-devel
三. zlib 安装
yum install -y zlib zlib-devel
四. OpenSSL 安装
yum install -y openssl openssl-devel
官网下载nginx
俩种办法:
1.直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
2.使用wget命令下载(推荐)。确保系统已经安装了wget,如果没有安装,执行 yum install wget 安装。
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
解压
tar -zxvf nginx-1.12.0.tar.gz
cd nginx-1.12.0
2 配置 编译
./configure --with-http_ssl_module //添加这个ssl模块
make
make install
3 看阿里云的教程
坑
nginx配置https无法开启443
按照教程如果netstat找不到443
那就看下nginx的日志,是否是重启失败了
收到the “ssl” parameter requires ngx_http_ssl_module报错:
重新编译Nginx并在编译安装的时候加上–with-http_ssl_module配置。
nginx.conf
server {
listen 80;
server_name 你的域名;
# 重定向到https
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name 你的域名;
ssl on;
root html;
index index.html index.htm;
ssl_certificate /usr/local/nginx/cert/sslconfigure.pem;
ssl_certificate_key /usr/local/nginx/cert/sslconfigure.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
#代理到自己开的服务端口上
proxy_pass http://localhost:2508;
client_max_body_size 10m;
}
}