nginx ssl 配置

目录

 

nginx SSL模块编译

pcre

zlib

nginx版本号:nginx-1.14.0

openssl版本号:OpenSSL 1.1.1

安装

nginx ssl证书生成

nginx ssl配置


nginx SSL模块编译

nginx版本号:nginx-1.14.0

cd /usr/local/

http://nginx.org/download/nginx-1.14.0.tar.gz

tar -xzvf nginx-1.14.0.tar.gz

openssl版本号:OpenSSL 1.1.1

cd /usr/local/

wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1.tar.gz

tar -xzvf OpenSSL_1_1_1.tar.gz

安装

cd nginx-1.14.0

yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel

./configure  --prefix=/usr/local/nginx  --with-http_stub_status_module --with-http_ssl_module   --with-pcre --with-openssl=/usr/local/openssl-OpenSSL_1_1_1/

make

nginx ssl证书生成

cd /usr/local/nginx/conf

openssl genrsa -des3 -out server.key 1024

openssl req -new -key server.key -out server.csr

openssl rsa -in server.key -out server_nopass.key

openssl x509 -req -days 36500 -in server.csr -signkey server.key -out server.crt

nginx ssl配置

server {
  listen 443;
  server_name www.domain.com; # 改为绑定证书的域名
  ssl on;
  ssl_certificate 1_www.domain.com_bundle.crt; # 改为自己申请得到的 crt 文件的名称
  ssl_certificate_key 2_www.domain.com.key; # 改为自己申请得到的 key 文件的名称
  ssl_session_timeout 5m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  ssl_prefer_server_ciphers on;

  location / {
    root /usr/share/nginx/html; #站点目录
    index index.html index.htm;
  }
}

你可能感兴趣的:(nginx ssl 配置)