Uvod
Uvod
Uvod
SSL (kratica od Secure Sockets Layer ) i njegov nasljednik, TLS (skraćenica za Transport Layer Security ) su kriptografski protokoli za sigurnu komunikaciju putem Interneta. Može se koristiti za stvaranje sigurne veze na web stranicu.
Uvod
Provjerite jesu li Nginx i OpenSSL instalirani na vašem poslužitelju. U ovom članku ćemo pokazati proces generiranjem samopotpisanog SSL certifikata.
Korak 1: Izradite imenik za certifikat i privatni ključ
Napravit ćemo direktorij (i unijeti ga) unutar /etc/nginx (pod pretpostavkom da je taj direktorij Nginxov konfiguracijski direktorij), tako da:
sudo mkdir /etc/nginx/ssl
cd /etc/nginx/ssl # we'll perform our next few steps in this dir
Korak 2: Napravite privatni ključ i CSR
Započnimo stvaranjem privatnog ključa stranice. U ovom primjeru koristit ćemo 4096-bitni ključ za veću sigurnost. Imajte na umu da je 2048-bitni također siguran, ali NEMOJTE KORISTITI 1024-BITNI PRIVATNI KLJUČ!
sudo openssl genrsa -out example.com.key 4096
Sada kreirajte zahtjev za potpisivanje certifikata (CSR) za potpisivanje certifikata. Koristit ćemo 512-bitni SHA-2. Obratite pažnju na -sha512opciju.
sudo openssl req -new -key example.com.key -out example.com.csr -sha512
Zatražit će popis polja koja je potrebno ispuniti. Provjerite je li Common Namepostavljeno na naziv vaše domene! Također, ostavite A challenge passwordi An optional company nameprazno.
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:CA
Locality Name (eg, city) []:LosAngeles
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Example Inc
Organizational Unit Name (eg, section) []:Security
Common Name (e.g. server FQDN or YOUR name) []:*.example.com
Email Address []:webmaster@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Korak 3: Potpišite svoju potvrdu
Skoro gotovo! Sada ga samo moramo potpisati. Nemojte zaboraviti zamijeniti 365 (istek nakon 365 dana) na broj dana koji želite.
sudo openssl x509 -req -days 365 -in example.com.csr -signkey example.com.key -out example.com.crt -sha512
Sada smo gotovi s izradom samopotpisanog certifikata.
Korak 4: Postavite
Otvorite Nginxov primjer SSL konfiguracijske datoteke:
sudo nano /etc/nginx/conf.d/example_ssl.conf
Poništite komentar unutar odjeljka ispod retka HTTPS poslužitelj . Uskladite svoju konfiguraciju s informacijama u nastavku, zamjenjujući example.comu server_nameretku naziv svoje domene ili IP adresu. Također postavite svoj korijenski direktorij.
# HTTPS server
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ecdh_curve secp384r1;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4; # no RC4 and known insecure cipher
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
Zatim ponovno pokrenite Nginx.
service nginx restart
Sada posjetite svoju web stranicu s httpsadresom ( https://your.address.tld). Vaš će web preglednik prikazati sigurnu vezu pomoću vašeg samopotpisanog certifikata.