When you want to host your own website at home, you also want an secure connection from the outside world to your raspberry pi so that not everyone can spy on the content.

You can protect your site with an free ssl certificate. To obtain one, install certbot.

sudo apt-get install certbot

Make sure port 80/TCP (http) is open, since certbot will check if your request is valid

sudo certbot certonly --standalone -d my.domain.com -d my.domain.com

Your response will look something like below

Your certificate files are now saved and you can use them in your nginx configuration like below;

server {
        listen 80;
        listen [::]:80;
        server_name my.domain.com;
        return 301 https://$server_name$request_uri;
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        server_name my.domain.com;
        ssl_certificate /etc/letsencrypt/live/my.domain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/my.domain.com/privkey.pem;
        ssl on;
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;

Leave a Reply

Your email address will not be published. Required fields are marked *