Skip to content

Instantly share code, notes, and snippets.

@nezahualcoyotl
Created October 2, 2021 00:34
Show Gist options
  • Save nezahualcoyotl/d2987847779e1826c93352b53b2c0ecb to your computer and use it in GitHub Desktop.
Save nezahualcoyotl/d2987847779e1826c93352b53b2c0ecb to your computer and use it in GitHub Desktop.
Fast and undetailed guide to install SSL certificate

Create the .key and .csr file by running this in the server

$ openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr

Choose a SSL provider and follow their instructions to upload the .csr file and download a newly generated .crt

The SSL provider provides a .ca-bundle besides the crt. We need to merge them into one file. The order is first the .crt content and then the .ca-bundle content.

Now upload the resulting file into the server, preferibly where the .key and .csr files are.

If you're using nginx, the configuration file should be something like this:

server { 
    listen 80; 
    server_name www.nom35oficial.com; #dominio 
    return 301 https://nom35oficial.com$request_uri; 
} 
server { 
    listen 80; 
    server_name nom35oficial.com; #dominio 
    return 301 https://nom35oficial.com$request_uri; 
} 
server { 
    listen 443; 
    ssl on; 
    server_name nom35oficial.com; #dominio 
    root /var/www/nom35/public; #ruta de la aplicación 
    ssl_certificate /var/www/certificates/nom35oficial.crt; #ruta del archivo .crt 
    ssl_certificate_key /var/www/certificates/nom35oficial.key; #ruta del archivo .key 

    #configuración específica para laravel 
        index index.php index.html index.htm; 
        location / { 
            try_files $uri $uri/ /index.php?q=$uri&$args; 
        } 
        
        #fin del a configuración específica para laravel 
        error_page 404 /404.html; 
        location ~ \.php$ { 
        include snippets/fastcgi-php.conf; 
        fastcgi_pass unix:/run/php/php7.3-fpm.sock; #asumiendo que este es el módulo usado para correr php 
    } 
}

Remember to create the link to the nginx config file by

ln -s ../sites-available/nombrearchivo nombrearchivo 

Now restart the nginx server and that should do

service nginx restart

Special thanks to @xenozahit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment