Instalación de Linux nginx + https (tls v1.2)
1. Preparativos
1.nginx-1.17.9.tar.gz
2.openssl-1.1.1m.tar.gz
2. Instalar
-
instalación de openssl
1. Copie openssl-1.1.1m.tar.gz a Linux y descomprima
tar -xvf openssl-1.1.1m.tar.gz
2. Ingrese a la carpeta openssl-1.1.1m para compilar e instalar.
cd openssl-1.1.1m ./config make make install
3. Verifique la versión de openssl
openssl version
-
instalación nginx
1. Copie nginx-1.17.9.tar.gz a Linux y descomprímalo
tar -xvf nginx-1.17.9.tar.gz
2. Ingrese a la carpeta nginx-1.17.9 para compilar e instalar
cd nginx-1.17.9 ./configure --prefix=/opt/nginx --with-http_ssl_module --with-openssl=/root/openssl-1.1.1m --with-http_realip_module make && make install
Descripción de parámetros:
–prefix=/opt/nginx especifica el directorio de instalación de nginx
–with-http_ssl_module Agregar módulo ssl nginx
–with-openssl=/root/openssl-1.1.1m especifica la ubicación de instalación de openssl a la que se hará referencia
3. Configurar nginx
-
dirección oficial de nginx de producción de certificados ssl
cd /usr/local/nginx/conf openssl genrsa -des3 -out server.key 1024 openssl req -new -key server.key -out server.csr cp server.key server.key.org openssl rsa -in server.key.org -out server.key openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Interpretación del comando:
openssl req -``new` `-key server.key -out server.csr 输出内容为: Enter pass phrase ``for` `root.key: ← 输入前面创建的密码 Country Name (``2` `letter code) [AU]:CN ← 国家代号,中国输入CN State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音 Locality Name (eg, city) []:BeiJing ← 市的全名,拼音 Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名 Organizational Unit Name (eg, section) []: ← 可以不输入 Common Name (eg, YOUR name) []: ← 输入域名,如:iot.conet.com Email Address []:admin``@mycompany``.com ← 电子邮箱,可随意填 Please enter the following ‘extra’ attributes to be sent with your certificate request A challenge password []: ← 可以不输入 An optional company name []: ← 可以不输入
-
modificación de nginx.conf
server { #1.15之下使用 #listen 443; #ssl on; #1.15之后使用 listen 443 ssl; server_name localhost; ssl_certificate /opt/nginx/conf/server.crt; ssl_certificate_key /opt/nginx/conf/server.key; #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_protocols TLSv1.2; }
-
reinicio de nginx
cd ../nginx ./nginx -s reload
-
verificación del navegador
#访问项目地址,开发者模式中可看到: The connection to this site is encrypted and authenticated using TLS 1.2, ECDHE_RSA with X25519, and AES_128_GCM.