Your Essential Queries
How To Create Self Signed SSL Certificate
We'll See How To Create and Use Self Signed SSL Certificate for Nginx Server:
1) Open Terminal
2) Make a directory to store SSL certificates:
- sudo makdir /etc/nginx/ssl;
3) Generate SSL certificate using openSSL
- sudo openssl req -x509 -days 60 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/self.key -out /etc/nginx/ssl/self.cert
4) Use SSL certificate with Nginx Server
- server {
- listen 80;
- server_name _;
- return 301 https://$host$request_uri;
- }
- server {
- listen 443;
- root "/var/www/hosting/public_html/public";
- index index.php index.html index.htm index.nginx-debian.html;
- server_name _;
- ssl_certificate /etc/nginx/ssl/self.cert;
- ssl_certificate_key /etc/nginx/ssl/self.key;
- location / {
- try_files $uri $uri/ =404;
- }
- location ~ \.php$ {
- include snippets/fastcgi-php.conf;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- }
- location ~ /\.ht {
- deny all;
- }
- }