1. Install the Nginx server and the required packages.
apt-get update
apt-get install nginx openssl
2. Create a private key and the website certificate using the OpenSSL command
Create a private key and the website certificate using the OpenSSL command.
mkdir /etc/nginx/certificate
cd /etc/nginx/certificate
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out nginx-certificate.crt -keyout nginx.key
3. On the option named COMMON_NAME, you need to enter the IP address or hostname.
4. nginx config before the changes
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
nginx config after the changes
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /etc/nginx/certificate/nginx-certificate.crt;
ssl_certificate_key /etc/nginx/certificate/nginx.key;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
No comments:
Post a Comment